Skip to content
Snippets Groups Projects
Commit e35d8bfe authored by Martynas Sudintas's avatar Martynas Sudintas
Browse files

refactored Bool::addToBool method

parent 3973eadc
No related branches found
No related tags found
No related merge requests found
...@@ -50,11 +50,13 @@ class Bool implements BuilderInterface ...@@ -50,11 +50,13 @@ class Bool implements BuilderInterface
*/ */
public function addToBool(BuilderInterface $bool, $type = self::MUST) public function addToBool(BuilderInterface $bool, $type = self::MUST)
{ {
if (in_array($type, [ self::MUST, self::MUST_NOT, self::SHOULD ])) { $constants = (new \ReflectionObject($this))->getConstants();
$this->container[$type][] = $bool;
} else { if (!in_array($type, $constants)) {
throw new \UnexpectedValueException(sprintf('The bool operator %s is not supported', $type)); throw new \UnexpectedValueException(sprintf('The bool operator %s is not supported', $type));
} }
$this->container[$type][] = $bool;
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment