Parse query parameter and get operator and value.

@param string $value
@param bool $is_negation

@return string[]

@throws InvalidArgumentException when unable to parse operator or value
494323
protected static function parseOperatorAndValue($value, $is_negation)
    {
        if ($result = static::parseComparisonOperator($value, $is_negation)) {
            return $result;
        }

        if ($result = static::parseLikeOperator($value, $is_negation)) {
            return $result;
        }

        if ($result = static::parseNullOperator($value, $is_negation)) {
            return $result;
        }

        if ($result = static::parseEqualsInOperator($value, $is_negation)) {
            return $result;
        }

        throw new InvalidArgumentException(sprintf('Unable to parse operator or value from "%s"', $value));
    }
1285577
public static function Parse( $value, bool $fixed = false )
   {

      $res = null;

      if ( ! self::TryParse( $value, $res, $fixed ) )
      {
         return false;
      }

      return $res;

   }
856638
public static function boolean($value, $options = null)
    {
        if (!is_null($options)) {
            $options = explode('|', $options);
        }

        if (sizeof($options) != 2) {
            $options = array('No', 'Yes');
        }

        return $options[!!$value];
    }
520064
private function validateLogicalOperator($value) 
    {
        $operator = strtoupper(trim($value));
        $isValid = in_array($operator, $this->logicalOperators);
        
        if($isValid === true) {
            return $operator;
        } 
        
        throw new \Exception("Logical operator $value is not supported.");
    }
551762
private function parseValue($value)
    {
        if (is_string($value))
            return new String_($value);
        if (is_bool($value))
            return new ConstFetch(new Name([$value ? 'true' : 'false']));
        if (is_float($value))
            return new DNumber($value);
        if (is_numeric($value))
            return new LNumber($value);
        if (is_array($value)) {
            $items = [];
            foreach ($value as $key => $value) {
                $items[] = new ArrayItem(
                    $this->parseValue($value),
                    $this->parseValue($key)
                );
            }
            return new Array_($items);
        }
        return null;
    }
303604
protected function invalidOperatorAndValue($operator, $value)
    {
        return is_null($value) && array_key_exists($operator, $this->operators) &&
        ! array_key_exists($operator, ['=', '<>', '!=']);
    }
930511
protected function checkValueStructure(BaseValue $value)
    {
        if (!is_float($value->latitude) && !is_int($value->latitude)) {
            throw new InvalidArgumentType(
                '$value->latitude',
                'float',
                $value->latitude
            );
        }
        if (!is_float($value->longitude) && !is_int($value->longitude)) {
            throw new InvalidArgumentType(
                '$value->longitude',
                'float',
                $value->longitude
            );
        }
        if (!is_string($value->address)) {
            throw new InvalidArgumentType(
                '$value->address',
                'string',
                $value->address
            );
        }
    }
1105133
public function orx($value)
    {
        if(!is_array($value)) {
            // get arguments 
            $value = func_get_args();
        }
        // Convert all values to 
        $conds = array_map(function($v) {
                if(is_string($v) && $this->getQueryParser()) {
                    return $this->getQueryParser()->parseExpression($v);
                } else if(!$v instanceof Expr\ConditionalExpression) {
                    throw new \InvalidArgumentException('');
                } 
                return $v;
            }, $value);

        //return new Expr\OrX($conds);
        return new Expr\LogicalExpression($conds, Expr\LogicalExpression::TYPE_OR);
    }
627752
public function whereCmp($field, $operator, $value)
    {
        if ($operator === '=') {
            $this->_filters[] = [$field => $this->normalizeValue($field, $value)];
        } elseif ($operator === '~=') {
            if ($this->_types && !isset($this->_types[$field])) {
                throw new InvalidArgumentException(['`:field` field is not exist in `:collection` collection',
                    'field' => $field,
                    'collection' => $this->getSource()
                ]);
            }

            if (is_scalar($value)) {
                if (is_int($value)) {
                    $this->_filters[] = [$field => ['$in' => [(string)$value, (int)$value]]];
                } elseif (is_float($value)) {
                    $this->_filters[] = [$field => ['$in' => [(string)$value, (float)$value]]];
                } else {
                    $this->_filters[] = [$field => ['$in' => [(string)$value, (int)$value, (float)$value]]];
                }
            } else {
                throw new InvalidValueException(['`:operator` operator is not  valid: value must be scalar value', 'operator' => $operator]);
            }
        } else {
            $operator_map = ['>' => '$gt', '>=' => '$gte', '<' => '$lt', '<=' => '$lte', '!=' => '$ne', '<>' => '$ne'];
            if (!isset($operator_map[$operator])) {
                throw new InvalidValueException(['unknown `:operator` operator', 'operator' => $operator]);
            }
            $this->_filters[] = [$field => [$operator_map[$operator] => $this->normalizeValue($field, $value)]];
        }

        return $this;
    }
203519
private static function prependOperator($value, $operator = null)
    {

        if ($operator) {
            $operator = StringHelper::toLowerCase($operator);

            if (in_array($operator, static::$operators) || $operator === 'not') {
                if (is_array($value)) {
                    $values = [];

                    foreach ($value as $v) {
                        $values[] = $operator . ($operator === 'not' ? ' ' : '') . $v;
                    }

                    return $values;
                }

                return $operator . ($operator === 'not' ? ' ' : '') . $value;
            }
        }

        return $value;
    }
1141967
public function extract($value)
    {
        if ($this->nullable && $value === null) {
            return null;
        }

        $return = [];
        if (is_array($value) || $value instanceof \Traversable) {
            foreach ($value as $key => $object) {
                $return[$key] = $this->hasOneStrategy->extract($object);
            }
        } else {
            throw new Exception\InvalidArgumentException(sprintf(
                'Value must be null (only if nullable option is enabled), or an array, or a Traversable: "%s" given',
                is_object($value) ? get_class($value) : gettype($value)
            ));
        }

        return $return;
    }
1358782
protected function getNegationWhenConfigured($value, $configuration)
    {
        if (!is_array($configuration) || empty($configuration['negate']) || (bool)$configuration['negate'] === false) {
            return $value;
        }

        return !((bool)$value);
    }
1016802
protected function processValue($value, $isRoot = false)
    {
        if (\is_array($value)) {
            foreach ($value as $k => $v) {
                if ($isRoot) {
                    $this->currentId = $k;
                }
                if ($v !== $processedValue = $this->processValue($v, $isRoot)) {
                    $value[$k] = $processedValue;
                }
            }
        } elseif ($value instanceof ArgumentInterface) {
            $value->setValues($this->processValue($value->getValues()));
        } elseif ($value instanceof Expression && $this->processExpressions) {
            $this->getExpressionLanguage()->compile((string) $value, ['this' => 'container']);
        } elseif ($value instanceof Definition) {
            $value->setArguments($this->processValue($value->getArguments()));
            $value->setProperties($this->processValue($value->getProperties()));
            $value->setMethodCalls($this->processValue($value->getMethodCalls()));

            $changes = $value->getChanges();
            if (isset($changes['factory'])) {
                $value->setFactory($this->processValue($value->getFactory()));
            }
            if (isset($changes['configurator'])) {
                $value->setConfigurator($this->processValue($value->getConfigurator()));
            }
        }

        return $value;
    }
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];
    }
91050
public function parseOne($val)
    {
        if ($val === null || $val === '') {
            if ($this->allowNull()) {
                return null;
            } else {
                throw new InvalidArgumentException(
                    'Value can not be NULL (not allowed)'
                );
            }
        }

        if (!is_array($val)) {
            $val = json_decode($val, true);
        }

        return $val;
    }
1242703
protected function getQueryOperator($value)
    {
        $fb = new FilterBuilder();
        $bit = abs($this->getBitForAttribute($this->flagName));
        $operator = $fb->bitwiseAnd('groupType', (string) $bit);
        $value = $this->options['invert'] ? !$value : $value;

        return $value ? $operator : $fb->bNot($operator);
    }
1205977
public static function parse($value, $normalize=true)
    {
        if ($value === '') return null;
        if ($value === 'NAN') return new Rational(NAN, 1);
        if ($value === 'INF') return new Rational(INF, 1);
        if ($value === '-INF') return new Rational(-INF, 1);

        $data = $value;

        $numbers = explode('/', $data);
        if (count($numbers) == 1) {
            $p = static::isSignedInteger($numbers[0]) ? intval($numbers[0]) : NAN;
            $q = 1;
        }
        elseif (count($numbers) != 2) {
            $p = NAN;
            $q = NAN;
        }
        else {
            $p = static::isSignedInteger($numbers[0]) ? intval($numbers[0]) : NAN;
            $q = static::isInteger($numbers[1]) ? intval($numbers[1]) : NAN;
        }

        if (is_nan($p) || is_nan($q)) throw new SyntaxErrorException();


        return new Rational($p, $q, $normalize);
    }