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

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

        if (!is_array($values)) {
            $values = [$values];
        }

        $not = (stripos($operator, 'NOT ') !== false);
        $or = (stripos($operator, 'OR ') !== false);

        if ($not) {
            if (empty($values)) {
                return $data;
            }

            if ($or) {
                return array_filter($data, function ($row) use ($column, $values) {
                    foreach ($values as $value) {
                        if (stripos($row[$column], $value) === false) {
                            return true;
                        }
                    }

                    return false;
                });
            }

            return array_filter($data, function ($row) use ($column, $values) {
                foreach ($values as $value) {
                    if (stripos($row[$column], $value) !== false) {
                        return false;
                    }
                }

                return true;
            });
        }

        if (empty($values)) {
            return [];
        }

        if ($or) {
            return array_filter($data, function ($row) use ($column, $values) {
                foreach ($values as $value) {
                    if (stripos($row[$column], $value) !== false) {
                        return true;
                    }
                }

                return false;
            });
        }

        return array_filter($data, function ($row) use ($column, $values) {
            foreach ($values as $value) {
                if (stripos($row[$column], $value) === false) {
                    return false;
                }
            }

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

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

        if (!is_array($values)) {
            $values = [$values];
        }

        $not = (stripos($operator, 'NOT ') !== false);
        $or = (stripos($operator, 'OR ') !== false);

        if ($not) {
            if (empty($values)) {
                return $data;
            }

            if ($or) {
                return array_filter($data, function ($row) use ($column, $values) {
                    foreach ($values as $value) {
                        if (stripos($row[$column], $value) === false) {
                            return true;
                        }
                    }

                    return false;
                });
            }

            return array_filter($data, function ($row) use ($column, $values) {
                foreach ($values as $value) {
                    if (stripos($row[$column], $value) !== false) {
                        return false;
                    }
                }

                return true;
            });
        }

        if (empty($values)) {
            return [];
        }

        if ($or) {
            return array_filter($data, function ($row) use ($column, $values) {
                foreach ($values as $value) {
                    if (stripos($row[$column], $value) !== false) {
                        return true;
                    }
                }

                return false;
            });
        }

        return array_filter($data, function ($row) use ($column, $values) {
            foreach ($values as $value) {
                if (stripos($row[$column], $value) === false) {
                    return false;
                }
            }

            return true;
        });
    }
protected function filterLikeCondition ( array $ data , $ operator , $ operands ) { if ( ! isset ( $ operands [ 0 ] , $ operands [ 1 ] ) ) { throw new InvalidParamException ( "Operator '$operator' requires two operands." ) ; } list ( $ column , $ values ) = $ operands ; if ( ! is_array ( $ values ) ) { $ values = [ $ values ] ; } $ not = ( stripos ( $ operator , 'NOT ' ) !== false ) ; $ or = ( stripos ( $ operator , 'OR ' ) !== false ) ; if ( $ not ) { if ( empty ( $ values ) ) { return $ data ; } if ( $ or ) { return array_filter ( $ data , function ( $ row ) use ( $ column , $ values ) { foreach ( $ values as $ value ) { if ( stripos ( $ row [ $ column ] , $ value ) === false ) { return true ; } } return false ; } ) ; } return array_filter ( $ data , function ( $ row ) use ( $ column , $ values ) { foreach ( $ values as $ value ) { if ( stripos ( $ row [ $ column ] , $ value ) !== false ) { return false ; } } return true ; } ) ; } if ( empty ( $ values ) ) { return [ ] ; } if ( $ or ) { return array_filter ( $ data , function ( $ row ) use ( $ column , $ values ) { foreach ( $ values as $ value ) { if ( stripos ( $ row [ $ column ] , $ value ) !== false ) { return true ; } } return false ; } ) ; } return array_filter ( $ data , function ( $ row ) use ( $ column , $ values ) { foreach ( $ values as $ value ) { if ( stripos ( $ row [ $ column ] , $ value ) === false ) { return false ; } } return true ; } ) ; }
Applies 'LIKE' 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 a single value
or an array of values that column value should be compared with

@return array filtered data

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