Check if a string is a valid operator
@param  string $operator
@param  string $attributeName Optional attribute's name, used for thrown exception
@throws \DomainException
@return string Returns the operator
@todo change attribute name to Source
428467
public static function validate(
        string $operator,
        $attributeName = null
    ) : string {
        $operator = Operator::getCanonical($operator);

        if (!in_array($operator, self::$operators)) {
            throw new \DomainException(
                $attributeName !== null
                ?  sprintf(
                    'Invalid operator "%s" for attribute "%s"',
                    $operator,
                    $attributeName
                )
                : sprintf(
                    'Invalid operator "%s"',
                    $operator
                )
            );
        }

        return $operator;
    }
52210
public function validationDomain($domain = null)
    {
        if ($domain === null) {
            return $this->_validationDomain;
        }
        $this->_validationDomain = $domain;
    }
892091
protected function validateRegex($attribute, $value, $parameters)
    {
        if (! is_string($value) && ! is_numeric($value)) {
            return false;
        }

        $this->requireParameterCount(1, $parameters, 'regex');

        return preg_match($parameters[0], $value);
    }
78096
protected function checkValue($testedValue, $operator, $argument)
    {
        switch ($operator) {
            case FilterOperation::OPERATOR_EQ:
                return $testedValue == $argument;
            case FilterOperation::OPERATOR_GT:
                return $testedValue > $argument;
            case FilterOperation::OPERATOR_GTE:
                return $testedValue >= $argument;
            case FilterOperation::OPERATOR_LT:
                return $testedValue < $argument;
            case FilterOperation::OPERATOR_LTE:
                return $testedValue <= $argument;
            case FilterOperation::OPERATOR_NOT_EQ:
                return $testedValue != $argument;
            case FilterOperation::OPERATOR_STR_CONTAINS:
                return strpos($testedValue, $argument) !== false;
            case FilterOperation::OPERATOR_STR_STARTS_WITH:
                return strpos($testedValue, $argument) === 0;
            case FilterOperation::OPERATOR_STR_ENDS_WITH:
                return strpos($testedValue, $argument, strlen($testedValue) - strlen($argument)) !== false;
            default:
                throw new InvalidArgumentException(
                    'Unsupported operator ' . $operator
                );
        }
    }
267192
protected function getFilterDescription(string $fieldName, string $operator): array
    {
        return [
            sprintf('%s[%s]', $fieldName, $operator) => [
                'property' => $fieldName,
                'type' => 'string',
                'required' => false,
            ],
        ];
    }
1366882
protected function mapConditionOperator(string $operator) : string
    {
        ConditionOperator::validate($operator);

        static $dbOperatorMap = [
            ConditionOperator::EQUALS                           => BinOp::EQUAL,
            ConditionOperator::NOT_EQUALS                       => BinOp::NOT_EQUAL,
            ConditionOperator::IN                               => BinOp::IN,
            ConditionOperator::NOT_IN                           => BinOp::NOT_IN,
            ConditionOperator::LESS_THAN                        => BinOp::LESS_THAN,
            ConditionOperator::LESS_THAN_OR_EQUAL               => BinOp::LESS_THAN_OR_EQUAL,
            ConditionOperator::GREATER_THAN                     => BinOp::GREATER_THAN,
            ConditionOperator::GREATER_THAN_OR_EQUAL            => BinOp::GREATER_THAN_OR_EQUAL,
            ConditionOperator::STRING_CONTAINS                  => BinOp::STR_CONTAINS,
            ConditionOperator::STRING_CONTAINS_CASE_INSENSITIVE => BinOp::STR_CONTAINS_CASE_INSENSITIVE,
        ];

        return $dbOperatorMap[$operator];
    }
1171079
public function check($model)
    {
        if ($this->isSubQuery()) {
            return Builder::make($model, $this->property)->check();
        }

        switch ($this->operator) {
            case '=':
                return $this->attribute($model) === $this->value();
            break;
            case '>=':
                return $this->attribute($model) >= $this->value();
            break;
            case '<=':
                return $this->attribute($model) <= $this->value();
            break;
            case '<>':
                return $this->attribute($model) !== $this->value();
            break;
            case '>':
                return $this->attribute($model) > $this->value();
            break;
            case '<':
                return $this->attribute($model) < $this->value();
            break;
            case 'like':
                $pattern = preg_quote($this->value());
                $pattern = str_replace('%', '(.*?)', $pattern);
                $pattern = str_replace('_', '(.)', $pattern);
                $pattern = '/^'.$pattern.'$/s';

                return preg_match($pattern, $this->attribute($model)) != false;
            break;
        }
        throw new BadMethodCallException('Operator not supported: '.$this->operator);
    }
647595
final protected static function validateOperator (string $operator, string $defaultOperator="=") : string
	{
		return static::isOperatorValid($operator) ? $operator : ($defaultOperator ?: '=');
	}
535531
protected function checkOperand($operand)
    {
        if (!is_scalar($operand) && !$operand instanceof ExpressionContract) {
            throw new InvalidArgumentException('Condition only acceps scalars and Expression, not ' . Type::of($operand));
        }
        return $operand;
    }
668724
private function _prepareUnaryExpression($operator, $child) {
        return $this->_iterName.$operator.self::OPEN_BRAKET.$child.self::CLOSE_BRACKET;
    }
943337
public static function getOperator($type, $operator)
    {
        $operators = self::getOperators($type);

        return Arr::get($operators, $operator, []);
    }
212134
private function bitwise(string $operator, string $a, string $b) : string
    {
        $this->init($a, $b, $aDig, $bDig, $aNeg, $bNeg);

        $aBin = $this->toBinary($aDig);
        $bBin = $this->toBinary($bDig);

        $aLen = \strlen($aBin);
        $bLen = \strlen($bBin);

        if ($aLen > $bLen) {
            $bBin = \str_repeat("\x00", $aLen - $bLen) . $bBin;
        } elseif ($bLen > $aLen) {
            $aBin = \str_repeat("\x00", $bLen - $aLen) . $aBin;
        }

        if ($aNeg) {
            $aBin = $this->twosComplement($aBin);
        }
        if ($bNeg) {
            $bBin = $this->twosComplement($bBin);
        }

        switch ($operator) {
            case 'and':
                $value = $aBin & $bBin;
                $negative = ($aNeg and $bNeg);
                break;

            case 'or':
                $value = $aBin | $bBin;
                $negative = ($aNeg or $bNeg);
                break;

            case 'xor':
                $value = $aBin ^ $bBin;
                $negative = ($aNeg xor $bNeg);
                break;

            // @codeCoverageIgnoreStart
            default:
                throw new \InvalidArgumentException('Invalid bitwise operator.');
            // @codeCoverageIgnoreEnd
        }

        if ($negative) {
            $value = $this->twosComplement($value);
        }

        $result = $this->toDecimal($value);

        return $negative ? $this->neg($result) : $result;
    }
1058343
private static String validateOperator(final String operator) {
        if (!OPERATORS.contains(operator) && !BOOLEAN_OPERATORS.contains(operator)) {
            throw new CitrusRuntimeException("Unknown operator '" + operator + "'");
        }
        return operator;
    }
908469
protected function operatorName($operator)
    {
        if (isset($this->_operatorNames[$operator])) {
            return $this->_operatorNames[$operator];
        }
        return strtolower($operator);
    }
1042164
private static function convertComparisonOperator($criteriaOperator)
    {
        return isset(self::$operatorMap[$criteriaOperator]) ? self::$operatorMap[$criteriaOperator] : null;
    }
332289
protected function evaluateOperator($value, $operator, $operand)
    {
        switch ($operator) {
            case '=':
                return $value === $operand;
            case '!=':
                return $value !== $operand;
            case '<':
                return $value < $operand;
            case '<=':
                return $value <= $operand;
            case '>':
                return $value > $operand;
            case '>=':
                return $value >= $operand;
            case '$=':
                if (is_array($value)) {
                    if ($this->evaluateOperator(end($value), '=', $operand)) {
                        return true;
                    }
                    return false;
                } else {
                    return strrpos($value, (string)$operand) === strlen($value) - strlen($operand);
                }
            case '^=':
                if (is_array($value)) {
                    if ($this->evaluateOperator(reset($value), '=', $operand)) {
                        return true;
                    }
                    return false;
                } else {
                    return strpos($value, (string)$operand) === 0;
                }
            case '*=':
                if (is_array($value)) {
                    foreach ($value as $item) {
                        if ($this->evaluateOperator($item, '=', $operand)) {
                            return true;
                        }
                    }
                    return false;
                } else {
                    return strpos($value, (string)$operand) !== false;
                }
            case 'instanceof':
                if ($this->operandIsSimpleType($operand)) {
                    return $this->handleSimpleTypeOperand($operand, $value);
                } else {
                    return ($value instanceof $operand);
                }
            case '!instanceof':
                if ($this->operandIsSimpleType($operand)) {
                    return !$this->handleSimpleTypeOperand($operand, $value);
                } else {
                    return !($value instanceof $operand);
                }
            default:
                return ($value !== null);
        }
    }
992400
protected function validate(array $values, $operator)
    {
        if (!in_array($operator, array('=', '!='))) {
            return $this->translation->text('Unsupported operator');
        }

        if (count($values) != 1) {
            return $this->translation->text('@field has invalid value', array(
                '@field' => $this->translation->text('Condition')));
        }

        $scope = filter_var(reset($values), FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);

        if (!isset($scope)) {
            return $this->translation->text('@field has invalid value', array(
                '@field' => $this->translation->text('Condition')));
        }

        return true;
    }