Validate if the comparisonOperator is supported.

@throws Exception
@return bool $operator
186710
private function validateComparisonOperators($value) 
    {
        $operator = strtoupper(trim($value));
        $isValid = in_array($operator, $this->comparisonOperators);
        
        if($isValid === true) {
            return $operator;
        } 
        
        throw new \Exception("Comparison operator $value is not supported.");
    }
761024
protected function compare($value)
    {
        if (!method_exists($this, self::$methodList[$this->operator])) {
            throw new FilterException("Method for {$this->operator} does not exist!");
        }

        return $this->{self::$methodList[$this->operator]}($value, $this->value);
    }
1014594
public function performCheck()
    {
        try {
            $supported = false;
            foreach ($this->connection->fetchAll('show engines') as $engine) {
                $engine = array_change_key_case($engine, CASE_LOWER);
                if (isset($engine['engine']) && strtolower($engine['engine']) == 'innodb') {
                    $supported = true;
                    break;
                }
            }
            if ($supported) {
                $result = new PreconditionResult(PreconditionResult::STATE_PASSED);
            } else {
                $result = new PreconditionResult(PreconditionResult::STATE_FAILED, t('Your MySQL database does not support InnoDB database tables. These are required.'));
            }
        } catch (Exception $x) {
            $result = new PreconditionResult(PreconditionResult::STATE_FAILED, $x->getMessage());
        }

        return $result;
    }
307020
public function allowOperators($operators)
    {
        if ($this->_allowedOperators) {
            throw new BadMethodCallException('You can only set the allowed operators once.');
        }
        $this->_allowedOperators = is_array($operators) ? $operators : func_get_args();
        $this->checkRestrictions();
        return $this;
    }
34548
protected function evaluate ()
  {
    $prop = $this->props;
    $np   = Parser::NAMELESS_PROP;
    $v    = isset ($prop->$np) ? $prop->$np : $prop->get ('value');
    $not  = $prop->not;

    if (exists ($prop->matches))
      return (bool)preg_match ("%$prop->matches%", $v) xor $not;

    if ($prop->case) {
      foreach ($prop->case as $param) {
        if ($v == $param->props->get ('is')) // Note that we use the loose comparison operator == here.
          return true;
      }
      return false;
    }

    return strToBool ($v) xor $not;
  }
571862
public function check($model)
    {
        if ($this->isSubQuery()) {
            return Builder::make($model, $this->property)->check() && Builder::make($model, $this->propertyToCompare)->check();
        }

        switch ($this->operator) {
            case '=':
                return $this->attribute($model, $this->property) === $this->attribute($model, $this->propertyToCompare);
                break;
            case '>=':
                return $this->attribute($model, $this->property) >= $this->attribute($model, $this->propertyToCompare);
                break;
            case '<=':
                return $this->attribute($model, $this->property) <= $this->attribute($model, $this->propertyToCompare);
                break;
            case '<>':
                return $this->attribute($model, $this->property) !== $this->attribute($model, $this->propertyToCompare);
                break;
            case '>':
                return $this->attribute($model, $this->property) > $this->attribute($model, $this->propertyToCompare);
                break;
            case '<':
                return $this->attribute($model, $this->property) < $this->attribute($model, $this->propertyToCompare);
                break;
        }
        throw new BadMethodCallException('Operator not supported: '.$this->operator);
    }
1294330
public function process()
    {
        $operands = $this->getOperands();

        if ($operands->containsNull()) {
            return null;
        }

        if ($operands->exclusivelyMultipleOrOrdered() === false) {
            $msg = "The Contains Expression only accept operands with multiple or ordered cardinality.";
            throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_CARDINALITY);
        }

        if ($operands->sameCardinality() === false) {
            $msg = "The Contains Expression only accept operands with the same cardinality.";
            throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_CARDINALITY);
        }

        if ($operands->sameBaseType() === false) {
            $msg = "The Contains Expression only accept operands with the same baseType.";
            throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_BASETYPE);
        }

        $operand1 = $operands[0];
        $operand2 = $operands[1];

        if ($operand1->getCardinality() === Cardinality::MULTIPLE) {
            foreach ($operand2 as $value) {
                if ($operand1->contains($value) === false || $operand1->occurences($value) !== $operand2->occurences($value)) {
                    return new QtiBoolean(false);
                }
            }

            return new QtiBoolean(true);
        } else {
            // $operand1->getCardinality() === Cardinality::ORDERED
            $op1Index = 0;
            $op2Index = 0;
            $lastFoundIndex = -1;
            $foundCount = 0;

            while ($op1Index < count($operand1)) {
                $op1Val = $operand1[$op1Index];
                $op2Val = $operand2[$op2Index];

                if ($op2Val === $op1Val || ($op2Val instanceof Comparable && $op2Val->equals($op1Val))) {
                    $op2Index++;

                    if ($lastFoundIndex >= 0 && ($op1Index - $lastFoundIndex) > 1) {
                        // Sequence not respected.
                        return new QtiBoolean(false);
                    } else {
                        $lastFoundIndex = $op1Index;
                        $foundCount++;
                    }
                }

                $op1Index++;
            }

            if ($foundCount > 0 && $foundCount === count($operand2)) {
                return new QtiBoolean(true);
            } else {
                return new QtiBoolean(false);
            }
        }
    }
637855
public function addCondition($field, $operator = UNDEFINED, $value = UNDEFINED)
    {
        if (!$this->controller) {
            throw $this->exception('Controller for this model is not set', 'NotImplemented');
        }
        if (!@$this->controller->supportConditions) {
            throw $this->exception('The controller doesn\'t support conditions', 'NotImplemented')
                ->addMoreInfo('controller', $this->controller);
        }
        if (is_array($field)) {
            foreach ($field as $value) {
                $this->addCondition($value[0], $value[1], count($value) === 2 ? UNDEFINED : $value[2]);
            }

            return $this;
        } elseif (($operator === UNDEFINED) && (!is_object($field))) { // controller can handle objects
            throw $this->exception('You must define the second argument');
        }
        if ($value === UNDEFINED) {
            $value = $operator;
            $operator = '=';
        }
        $supportOperators = $this->controller->supportOperators;
        if ($supportOperators !== 'all' && (is_null($supportOperators) || (!isset($supportOperators[$operator])))) {
            throw $this->exception('Unsupport operator', 'NotImplemented')
                ->addMoreInfo('operator', $operator);
        }

        $this->conditions[] = array($field, $operator, $value);

        return $this;
    }
1275749
public function verify(): bool
    {
        if (!$this->callback) {
            throw new \Exception('Callbacks need to exist to run verify.');
        }

        $pactJson = $this->reify();

        // call the function to actually run the logic
        try {
            \call_user_func($this->callback, $pactJson);

            return $this->writePact();
        } catch (\Exception $e) {
            return false;
        }
    }
911309
protected function detectOperator()
    {
        if ($this->startsWith($this->version, self::GREATER_EQUAL))
        {
            $this->operator = self::GREATER_EQUAL;
            $this->version = substr($this->version, 2);
        }
        else if ($this->startsWith($this->version, self::GREATER))
        {
            $this->operator = self::GREATER;
            $this->version = substr($this->version, 1);
        }
        else if ($this->startsWith($this->version, self::TILDE))
        {
            $this->operator = self::TILDE;
            $this->version = substr($this->version, 1);
        }
    }
479902
public function checkCompare($left, $operator, $right, $strict=false)
    {

        if ($strict || in_array($operator, ['is', 'is not', '=', '!=', '<>'])) {
            return $this->isComparable($left, $right) ? $this->compare($left, $operator, $right) : false;
        }

        if (!$comparable = $this->makeComparable($left, $right)) {
            return false;
        }

        list($left, $right) = $comparable;

        return $this->compare($left, $operator, $right);
    }
342917
protected function invalidOperator($operator)
    {
        return ! in_array(strtolower($operator), $this->operators, true) &&
               ! in_array(strtolower($operator), $this->grammar->getOperators(), true);
    }
350152
public function allowOperators($operators)
    {
        $operators = is_array($operators) ? $operators : func_get_args();
        if ($this->allowedOperators && $this->allowedOperators != $operators) {
            throw new BadMethodCallException('You can only set the allowed operators once.');
        }
        $this->allowedOperators = $operators;
        return $this->setOperator($this->operator);
    }
1084607
public function isValid()
    {
        $value = $this->field->getValue();

        if (is_array($value) || is_object($value)) {
            throw new \Exception("This validator only works on scalar types!");
        }

        // required but not given
        if ($this->required && $value == null) {
            return false;
        } // if the field is not required and the value is empty, then it's also valid
        elseif (!$this->required && $value == "") {
            return true;
        }

        $len = strlen($value);

        // shorter then min length
        if ($len < $this->getMinLength()) {
            return false;
        }

        // bigger then the given length
        if ($this->getMaxLength() > 0 && $len > $this->getMaxLength()) {
            return false;
        }

        return true;
    }
1255022
public static function compare($compare1, $operator, $compare2, $strict = false)
    {
        $operator = trim(strtolower($operator));

        switch ($operator) {
            case '=':
            case '==':
            case 'eq':
                return $strict ? $compare1 === $compare2 : $compare1 == $compare2;
                break;

            case '===':
                return $compare1 === $compare2;
                break;

            case '!=':
            case 'neq':
                return $strict ? $compare1 !== $compare2 : $compare1 != $compare2;
                break;

            case '!==':
                return $compare1 !== $compare2;
                break;

            case '>':
            case 'gt':
                return $compare1 > $compare2;
                break;

            case '>=':
            case 'gte':
                return $compare1 >= $compare2;
                break;

            case '<':
            case 'lt':
                return $compare1 < $compare2;
                break;

            case '<=':
            case 'lte':
                return $compare1 <= $compare2;
                break;

            case 'in':
                return in_array($compare1, static::toArray($compare2), $strict);
                break;

            case 'not in':
            case 'not-in':
            case 'notin':
            case 'nin':
                return !in_array($compare1, static::toArray($compare2), $strict);
                break;

            default:
                throw new \InvalidArgumentException('Invalid compare operator: ' . $operator);
        }
    }
108805
public function process()
    {
        $operands = $this->getOperands();
        $allFalse = true;

        foreach ($operands as $op) {
            if ($op instanceof Container) {
                $msg = "The Or Expression only accept operands with single cardinality.";
                throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_CARDINALITY);
            } elseif ($op === null) {
                continue;
            } else {
                if (!$op instanceof QtiBoolean) {
                    $msg = "The Or Expression only accept operands with boolean baseType.";
                    throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_BASETYPE);
                } else {
                    if ($op->getValue() !== false) {
                        $allFalse = false;
                    }
                }
            }
        }

        if ($allFalse === true && $operands->containsNull() === true) {
            return null;
        }

        foreach ($operands as $operand) {
            if ($operand !== null && $operand->getValue() === true) {
                return new QtiBoolean(true);
            }
        }

        return new QtiBoolean(false);
    }
939910
public function comparisonExpression()
    {
        $this->lexer->glimpse();

        $leftExpr  = $this->arithmeticPrimary();
        $operator  = $this->comparisonOperator();
        $rightExpr = $this->arithmeticPrimary();

        return new ComparisonExpressionNode($leftExpr, $operator, $rightExpr);
    }