Filters a list of associative arrays, based on a set of key => value arguments.

@param array $args An array of key => value arguments to match against
@param string $operator
@return array
511115
private function query_spec( $args, $operator = 'AND' ) {
		$operator = strtoupper( $operator );
		$count    = count( $args );
		$filtered = array();

		foreach ( $this->spec as $key => $to_match ) {
			$matched = 0;
			foreach ( $args as $m_key => $m_value ) {
				if ( array_key_exists( $m_key, $to_match ) && $m_value === $to_match[ $m_key ] ) {
					$matched++;
				}
			}

			if ( ( 'AND' === $operator && $matched === $count )
				|| ( 'OR' === $operator && $matched > 0 )
				|| ( 'NOT' === $operator && 0 === $matched ) ) {
					$filtered[ $key ] = $to_match;
			}
		}

		return $filtered;
	}
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
                );
        }
    }
871811
protected function isOperatorAllowed(BaseOperator $operator)
    {
        if (!empty($this->children)) {
            throw new \RuntimeException('The "Not" operator can only have 1 child operator.');
        }
        if ($operator instanceof ContainsOperatorsInterface) {
            throw new LdapQueryException('Cannot add an operator to bNot that can contain other operators.');
        }
    }
1220414
public function serialize(Operator $operator)
    {
        switch(get_class($operator)) {
            case EqualTo::class:
                return array('name' => 'equal-to', 'value' => $operator->getValue());
            case GreaterThan::class:
                return array('name' => 'greater-than', 'value' => $operator->getValue());
            case GreaterThanEqual::class:
                return array('name' => 'greater-than-equal', 'value' => $operator->getValue());
            case HasIntersection::class:
                return array('name' => 'has-intersection', 'values' => $operator->getValues());
            case InSet::class:
                return array('name' => 'in-set', 'values' => $operator->getValues());
            case NotInSet::class:
                return array('name' => 'not-in-set', 'values' => $operator->getValues());
            case LessThan::class:
                return array('name' => 'less-than', 'value' => $operator->getValue());
            case LessThanEqual::class:
                return array('name' => 'less-than-equal', 'value' => $operator->getValue());
            case Percentage::class:
                return array('name' => 'percentage', 'percentage' => $operator->getPercentage(), 'shift' => $operator->getShift());
            case MatchesRegex::class:
                return array('name' => 'matches-regex', 'value' => $operator->getValue());
            default:
                throw new RuntimeException(sprintf('Unknown operator %s.', get_class($operator)));
        }
    }
155389
private function mapOperator($operator)
    {
        if (array_key_exists($operator, $this->shortOperators)) {
            $operator = $this->shortOperators[$operator];
        }

        if (!in_array($operator, $this->allowedOperators)) {
            throw new InvalidArgumentException(sprintf(
                'Invalid operator `%s` given. Valid operators are %s.',
                $operator,
                implode(', ', $this->allowedOperators)
            ));
        }

        return $operator;
    }
669406
public function setFilterDefaultOperation($operator)
    {
        if (! in_array($operator, Filter::AVAILABLE_OPERATORS)) {
            throw new \InvalidArgumentException(sprintf('Invalid filter operator \'%s\'', strval($operator)));
        }

        $this->filterDefaultOperation = $operator;

        return $this;
    }
371356
protected function parseIUD($args,$operation)
	{
		if(isset($args[2]))
		{
			// 三个参数齐全
			list($table,$data,$return) = $args;
		}
		else if(isset($args[1]))
		{
			// 数据+返回值
			list($data,$return) = $args;
		}
		else if(isset($args[0]))
		{
			// 一个参数的情况
			if(is_array($args[0]))
			{
				// 数据
				$data = $args[0];
			}
			else
			{
				// 表名
				$table = $args[0];
			}
			$return = Db::RETURN_ISOK;
		}
		$result = $this->execute($this->{'build' . $operation . 'SQL'}($table, $data));
		if(Db::RETURN_ROWS === $return)
		{
			return $this->rowCount();
		}
		else if(Db::RETURN_INSERT_ID === $return)
		{
			return $this->lastInsertId();
		}
		else
		{
			return $result;
		}
	}
387999
protected function compare($a, $b, $operator)
    {
        settype($a, 'array');
        settype($b, 'array');

        if (in_array($operator, array('>=', '<=', '>', '<'))) {
            $a = reset($a);
            $b = reset($b);
        }

        switch ($operator) {
            case '>=':
                return $a >= $b;
            case '<=':
                return $a <= $b;
            case '>':
                return $a > $b;
            case '<':
                return $a < $b;
            case '=':
                return count(array_intersect($a, $b)) > 0;
            case '!=':
                return count(array_intersect($a, $b)) == 0;
        }

        return false;
    }
901365
private function getOperatorConfiguration(array $operators): array
    {
        $conf = [];
        foreach ($operators as $operator => $leafType) {
            $instance = $this->types->getOperator($operator, $leafType);
            $field = [
                'name' => $this->getOperatorFieldName($operator),
                'type' => $instance,
            ];

            $conf[] = $field;
        }

        return $conf;
    }
1365673
private function filtersDefaultOperators(array $filters): array
    {
        foreach ($filters as $key => $filter) {
            // give the filter default operators, according to its type
            if (
                (!array_key_exists('operators', $filter)) ||
                (empty($filter['operators']))
            ) {
                $builderType = $filter['type'];

                switch ($builderType) {
                    case 'string':
                        $filter['operators'] = [
                            'equal', 'not_equal', 'is_null', 'is_not_null',
                            'begins_with', 'not_begins_with', 'contains', 'not_contains', 'ends_with', 'not_ends_with', 'is_empty', 'is_not_empty', // specific to strings
                        ];

                        break;
                    case 'integer':
                    case 'double':
                    case 'date':
                    case 'time':
                    case 'datetime':
                        $filter['operators'] = [
                            'equal', 'not_equal', 'is_null', 'is_not_null',
                            'less', 'less_or_equal', 'greater', 'greater_or_equal', 'between', 'not_between', // specific to numbers and dates
                        ];

                        break;
                    case 'boolean':
                        $filter['operators'] = [
                            'equal', 'not_equal', 'is_null', 'is_not_null',
                        ];

                        break;
                }
            }
            $filters[$key] = $filter;
        }

        return $filters;
    }
748826
public function setOperator($operator)
    {
        if (!in_array($operator, $this->supportedOperators)) {
            $list = implode('|', $this->supportedOperators);
            throw new InvalidArgumentException("operator has to be $list, not $operator");
        }
        $this->operator = $operator;
        $this->toStringSeparator = ' ' . strtoupper($operator) . ' ';
        return $this;
    }
1207699
public function setMainOperator($operator)
    {
        switch ($operator) {
            case self::OPERATOR_AND :
                $this->mainOperator = self::OPERATOR_AND;
                break;
            case self::OPERATOR_OR :
                $this->mainOperator = self::OPERATOR_OR;
                break;
            default :
                throw new \InvalidArgumentException(__CLASS__ . '::' . __FUNCTION__ . '() First argument should be ' . __CLASS__ . '::OPERATOR_AND or ' . __CLASS__ . '::OPERATOR_OR constant');
                break;
        }
        $this->rootOperation->setOperator($this->mainOperator);
    }
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;
    }
342917
protected function invalidOperator($operator)
    {
        return ! in_array(strtolower($operator), $this->operators, true) &&
               ! in_array(strtolower($operator), $this->grammar->getOperators(), true);
    }
67000
private static function filterInList($operation, &$params)
    {
        $params    = \array_merge($params, \array_values($operation['values']));
        $wildcards = \rtrim(\str_repeat('?,', \count($operation['values'])), ',');

        return \sprintf('(%s IN (%s))', $operation['property'], $wildcards);
    }
1094551
private function validateOperator(string $operator)
    {
        if (!in_array($operator, self::VALID_OPERATORS)) {
            throw new \InvalidArgumentException(sprintf(
                '%s is not a valid operator'
            ), $operator);
        }
    }
1302460
public function route(array $values, $operator)
    {
        if (!in_array($operator, array('=', '!='))) {
            return $this->translation->text('Unsupported operator');
        }

        $existing = $this->route->getList();

        foreach ($values as $pattern) {
            if (empty($existing[$pattern])) {
                return $this->translation->text('@name is unavailable', array(
                    '@name' => $this->translation->text('Condition')));
            }
        }

        return true;
    }