diff --git a/Bool/Bool.php b/Bool/Bool.php index 589be164b1bb2f6aec8845d9d477e005691ed336..69194fe9003a43166099705d67797513c1081cf9 100644 --- a/Bool/Bool.php +++ b/Bool/Bool.php @@ -50,11 +50,13 @@ class Bool implements BuilderInterface */ public function addToBool(BuilderInterface $bool, $type = self::MUST) { - if (in_array($type, [ self::MUST, self::MUST_NOT, self::SHOULD ])) { - $this->container[$type][] = $bool; - } else { + $constants = (new \ReflectionObject($this))->getConstants(); + + if (!in_array($type, $constants)) { throw new \UnexpectedValueException(sprintf('The bool operator %s is not supported', $type)); } + + $this->container[$type][] = $bool; } /**