public function toBoolean(Form $form)
 {
     $left = $form->toFormValue($this->left);
     $right = $form->toFormValue($this->right);
     $both = null !== $left && null !== $right;
     return $both && mb_strtolower($left) === mb_strtolower($right);
 }
Example #2
0
 public function toBoolean(Form $form)
 {
     $left = $form->toFormValue($this->left);
     $right = $form->toFormValue($this->right);
     $value = $form->toFormValue($this->field);
     return $left <= $value && $value <= $right;
 }
 public function toBoolean(Form $form)
 {
     Assert::isTrue($this->brackets, 'brackets must be enabled');
     $subject = $form->toFormValue($this->subject);
     switch ($this->logic) {
         case self::NOT:
             return false === $subject;
         default:
             throw new UnsupportedMethodException("'{$this->logic}' doesn't supported yet");
     }
 }
Example #4
0
 public function toBoolean(Form $form)
 {
     $left = $form->toFormValue($this->left);
     $right = $this->right;
     $both = null !== $left && null !== $right;
     switch ($this->logic) {
         case self::IN:
             return $both && in_array($left, $right);
         case self::NOT_IN:
             return $both && !in_array($left, $right);
         default:
             throw new UnsupportedMethodException("'{$this->logic}' doesn't supported");
     }
 }
Example #5
0
 public function toBoolean(Form $form)
 {
     Assert::isTrue($this->brackets, 'brackets must be enabled');
     $left = $form->toFormValue($this->left);
     $right = $form->toFormValue($this->right);
     $both = null !== $left && null !== $right;
     switch ($this->logic) {
         case self::EQUALS:
             return $both && $left == $right;
         case self::NOT_EQUALS:
             return $both && $left != $right;
         case self::GREATER_THAN:
             return $both && $left > $right;
         case self::GREATER_OR_EQUALS:
             return $both && $left >= $right;
         case self::LOWER_THAN:
             return $both && $left < $right;
         case self::LOWER_OR_EQUALS:
             return $both && $left <= $right;
         case self::EXPRESSION_AND:
             return $both && ($left && $right);
         case self::EXPRESSION_OR:
             return $both && ($left || $right);
         case self::ADD:
             return $both && $left + $right;
         case self::SUBSTRACT:
             return $both && $left - $right;
         case self::MULTIPLY:
             return $both && $left * $right;
         case self::DIVIDE:
             return $both && $right && $left / $right;
         case self::MOD:
             return $both && $right && $left % $right;
         case self::REGEXP:
             return preg_match("/{$right}/i", $left);
         case self::NOT_REGEXP:
             return !preg_match("/{$right}/i", $left);
         default:
             throw new UnsupportedMethodException("'{$this->logic}' doesn't supported yet");
     }
 }