protected function filterInCondition(array $data, $operator, $operands)
    {
        if (!isset($operands[0], $operands[1])) {
            throw new InvalidParamException("Operator '$operator' requires two operands.");
        }

        list($column, $values) = $operands;

        if ($values === [] || $column === []) {
            return $operator === 'IN' ? [] : $data;
        }

        $values = (array) $values;

        if (count($column) > 1) {
            throw new InvalidParamException("Operator '$operator' allows only a single column.");
        }

        if (is_array($column)) {
            $column = reset($column);
        }

        foreach ($values as $i => $value) {
            if (is_array($value)) {
                $values[$i] = isset($value[$column]) ? $value[$column] : null;
            }
        }

        if (strncmp('NOT', $operator, 3) === 0) {
            return array_filter($data, function ($row) use ($column, $values) {
                return !in_array($row[$column], $values);
            });
        }

        return array_filter($data, function ($row) use ($column, $values) {
            return in_array($row[$column], $values);
        });
    }
protected function filterInCondition(array $data, $operator, $operands)
    {
        if (!isset($operands[0], $operands[1])) {
            throw new InvalidParamException("Operator '$operator' requires two operands.");
        }

        list($column, $values) = $operands;

        if ($values === [] || $column === []) {
            return $operator === 'IN' ? [] : $data;
        }

        $values = (array) $values;

        if (count($column) > 1) {
            throw new InvalidParamException("Operator '$operator' allows only a single column.");
        }

        if (is_array($column)) {
            $column = reset($column);
        }

        foreach ($values as $i => $value) {
            if (is_array($value)) {
                $values[$i] = isset($value[$column]) ? $value[$column] : null;
            }
        }

        if (strncmp('NOT', $operator, 3) === 0) {
            return array_filter($data, function ($row) use ($column, $values) {
                return !in_array($row[$column], $values);
            });
        }

        return array_filter($data, function ($row) use ($column, $values) {
            return in_array($row[$column], $values);
        });
    }
protected function filterInCondition ( array $ data , $ operator , $ operands ) { if ( ! isset ( $ operands [ 0 ] , $ operands [ 1 ] ) ) { throw new InvalidParamException ( "Operator '$operator' requires two operands." ) ; } list ( $ column , $ values ) = $ operands ; if ( $ values === [ ] || $ column === [ ] ) { return $ operator === 'IN' ? [ ] : $ data ; } $ values = ( array ) $ values ; if ( count ( $ column ) > 1 ) { throw new InvalidParamException ( "Operator '$operator' allows only a single column." ) ; } if ( is_array ( $ column ) ) { $ column = reset ( $ column ) ; } foreach ( $ values as $ i => $ value ) { if ( is_array ( $ value ) ) { $ values [ $ i ] = isset ( $ value [ $ column ] ) ? $ value [ $ column ] : null ; } } if ( strncmp ( 'NOT' , $ operator , 3 ) === 0 ) { return array_filter ( $ data , function ( $ row ) use ( $ column , $ values ) { return ! in_array ( $ row [ $ column ] , $ values ) ; } ) ; } return array_filter ( $ data , function ( $ row ) use ( $ column , $ values ) { return in_array ( $ row [ $ column ] , $ values ) ; } ) ; }
Applies 'IN' condition.

@param array $data data to be filtered
@param string $operator operator
@param array $operands the first operand is the column name.
The second operand is an array of values that column value should be among

@return array filtered data

@throws InvalidParamException if wrong number of operands have been given
Applies IN condition .