src/Braincrafted/ArrayQuery/WhereEvaluation.php
public function evaluate(array $item, array $clause)
    {
        if (false === isset($clause['key']) ||
            false === isset($clause['value']) ||
            false === isset($clause['operator'])
        ) {
            throw new \InvalidArgumentException('Clause must contain "key", "value" and operator.');
        }

        $value = isset($item[$clause['key']]) ? $item[$clause['key']] : null;
        $value = $this->evaluateFilters($value, $clause);

        if (false === isset($this->operators[$clause['operator']])) {
            throw new UnkownOperatorException(sprintf('The operator "%s" does not exist.', $clause['operator']));
        }

        if (false === $this->operators[$clause['operator']]->evaluate($value, $clause['value'])) {
            return false;
        }

        return true;
    }
public function evaluate(array $item, array $clause)
    {
        if (false === isset($clause['key']) ||
            false === isset($clause['value']) ||
            false === isset($clause['operator'])
        ) {
            throw new \InvalidArgumentException('Clause must contain "key", "value" and operator.');
        }

        $value = isset($item[$clause['key']]) ? $item[$clause['key']] : null;
        $value = $this->evaluateFilters($value, $clause);

        if (false === isset($this->operators[$clause['operator']])) {
            throw new UnkownOperatorException(sprintf('The operator "%s" does not exist.', $clause['operator']));
        }

        if (false === $this->operators[$clause['operator']]->evaluate($value, $clause['value'])) {
            return false;
        }

        return true;
    }
public function evaluate ( array $ item , array $ clause ) { if ( false === isset ( $ clause [ 'key' ] ) || false === isset ( $ clause [ 'value' ] ) || false === isset ( $ clause [ 'operator' ] ) ) { throw new \ InvalidArgumentException ( 'Clause must contain "key", "value" and operator.' ) ; } $ value = isset ( $ item [ $ clause [ 'key' ] ] ) ? $ item [ $ clause [ 'key' ] ] : null ; $ value = $ this -> evaluateFilters ( $ value , $ clause ) ; if ( false === isset ( $ this -> operators [ $ clause [ 'operator' ] ] ) ) { throw new UnkownOperatorException ( sprintf ( 'The operator "%s" does not exist.' , $ clause [ 'operator' ] ) ) ; } if ( false === $ this -> operators [ $ clause [ 'operator' ] ] -> evaluate ( $ value , $ clause [ 'value' ] ) ) { return false ; } return true ; }
Evaluates the given item with the given clause.

@param array $item   The item to evaluate.
@param array $clause The clause to evaluate the item with. Has to contain `key`, `value` and `operator` and can
optionally also contain `filters`. `filters` can be either a string or an array.

@return boolean `true` if the item evaluates to `true`, `false` otherwise.

@throws \InvalidArgumentException if `key`, `value` or `operator` is missing in `$clause`.
@throws Braincrafted\ArrayQuery\Exception\UnkownFilterException if a filter does not exist.
@throws Braincrafted\ArrayQuery\Exception\UnkownOperatorException if the operator does not exist.
Evaluates the given item with the given clause .