Retrieves an operator from the available operators.

Throws an AdldapException if no operator is found.

@param $operator

@return string

@throws InvalidQueryOperator
18425
private function getOperator($operator)
    {
        $operators = $this->getOperators();

        $key = array_search(strtolower($operator), $operators);

        if ($key !== false && array_key_exists($key, $operators)) {
            return $operators[$key];
        }

        $operators = implode(', ', $operators);

        $message = "Operator: $operator cannot be used in an LDAP query. Available operators are $operators";

        throw new InvalidQueryOperator($message);
    }
908469
protected function operatorName($operator)
    {
        if (isset($this->_operatorNames[$operator])) {
            return $this->_operatorNames[$operator];
        }
        return strtolower($operator);
    }
700719
protected function _operator($operator, $conditions, &$states)
    {
        if (isset($this->_operators[$operator])) {
            $config = $this->_operators[$operator];
        } elseif (substr($operator, -2) === '()') {
            $op = substr($operator, 0, -2);
            if (isset($this->_operators[$op])) {
                return '(' . $this->_operator($op, $conditions, $states) . ')';
            }
            $config = ['builder' => 'function'];
        } else {
            throw new SqlException("Unexisting operator `'{$operator}'`.");
        }
        $parts = $this->_conditions($conditions, $states);

        $operator = (is_array($parts) && next($parts) === 'NULL' && isset($config['null'])) ? $config['null'] : $operator;
        $operator = $operator[0] === ':' ? strtoupper(substr($operator, 1)) : $operator;

        if (isset($config['builder'])) {
            $builder = $this->_builders[$config['builder']];
            return $builder($operator, $parts);
        }
        if (isset($config['format'])) {
            return sprintf($config['format'], join(", ", $parts));
        }
        return join(" {$operator} ", $parts);
    }
124259
public function operator($left, $operator, $right, $message = '')
    {
        if (!isset(static::$operators[$operator])) {
            throw new \InvalidArgumentException("Invalid operator $operator");
        }
        $this->assertion->setActual($left);

        return $this->assertion->{static::$operators[$operator]}($right, $message);
    }
253978
public function removeOperator(string $operator): self
    {
        $this->validateOperator($operator);
        if (false !== ($key = array_search($operator, $this->operators))) {
            unset($this->operators[$key]);
        }

        return $this;
    }
1320058
protected function invalidOperatorAndValue($operator, $value)
    {
        $isOperator = in_array($operator, $this->operators);

        return is_null($value) && $isOperator && ! in_array($operator, ['=', '<>', '!=']);
    }
1118279
public function setOperator($operator)
    {
        if ($this->allowedOperators && !in_array($operator, $this->allowedOperators)) {
            throw new UnsupportedParameterException('This constraint only accepts operators: ' . implode(',', $this->allowedOperators));
        }

        $this->operator = $operator;
        return $this;
    }
1282103
protected function prepareValueAndOperator($value, $operator, $useDefault = false)
    {
        if ($useDefault) {
            return [$operator, '='];
        }
        if ($this->invalidOperatorAndValue($operator, $value)) {
            throw new InvalidArgumentException('Illegal operator and value combination.');
        }

        return [$value, $operator];
    }
1341035
public static function getComparator($operator)
    {
        if (!isset(self::$operators[$operator])) {
            if (count(self::$operatorsMap)) {
                self::initMap();
            }

            if (!isset(self::$operators[$operator])) {
                throw new \Exception(sprintf('"%s" operator not found', $operator));
            }
        }

        return self::$operators[$operator];
    }
943337
public static function getOperator($type, $operator)
    {
        $operators = self::getOperators($type);

        return Arr::get($operators, $operator, []);
    }
887062
protected function prepareValueAndOperator($value, $operator)
    {
        if (is_null($value) && ! in_array($operator, ['='])) {
            $value = $operator;
            $operator = '=';
        } elseif (! in_array($operator, ['='])) {
            throw new \InvalidArgumentException('Illegal operator and value combination.');
        }

        if (is_null($value)) {
            $value = 'NULL';
            $operator = 'IS';
        } else {
            $value = compact('value');
        }

        return [$value, $operator];
    }
744446
protected function callableOrFail(string $operator): callable
    {
        $callable = $this->config($operator, 'callable');

        if (is_string($callable) && method_exists($this->model, $callable)) {
            return [$this->model, $callable];
        }

        if (is_callable($callable)) {
            return $callable;
        }

        throw new DynamicMutatorNotCallableException('The given callable is invalid!', 0, null, [
            'callable' => $callable,
            'handler'  => $this->getName(),
        ]);
    }
172767
private function prepareOperator(?string $operator, $value): string
    {
        $operator = strtoupper($operator);

        if (!$operator) {
            $operator = is_array($value) ? 'IN' : '=';
        }

        if ($operator === 'IN' and !is_array($value)) {
            $operator = '=';
        }

        if ($operator !== 'IN' and is_array($value)) {
            throw new SqlException('Value could not be an array in condition for operator `' . $operator . '`.');
        }

        return $operator;
    }
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];
    }
231239
public function setOperators(array $operators)
    {
        $invalid = [];
        if (!$this->validateOperators($operators, $invalid)) {
            throw new \InvalidArgumentException(\sprintf('Trying to set invalid operator(s) "%s" for filter "%s"', \implode(', ', $operators), $this->getName()));
        }
        $this->operators = $operators;

        return $this;
    }
957012
public static function normaliseOperator($operator)
    {
        switch ($operator) {
            case 'add':
            case 'addition':
                $operator = '+';
                break;
            case 'sub':
            case 'subtract':
                $operator = '-';
                break;
            case 'mul':
            case 'multiply':
                $operator = '*';
                break;
            case 'div':
            case 'divide':
                $operator = '/';
                break;
            case 'mod':
            case 'modulus':
                $operator = '%';
                break;
            case 'comp':
            case 'compare':
                $operator = '=';
                break;
        }
        return $operator;
    }
1213286
private function _where($operator, array $fields)
    {
        $count = count($fields);

        if ($count < 1 || $count > 3)
        {
            $fields = var_export($fields, true);
            throw new \InvalidArgumentException($fields);
        }

        $this->storageWhere[] = [$operator => $fields];

        return $this;
    }