Lazer\Classes\Core_Database::wherePending PHP Method

wherePending() protected method

Filter function for array_filter() in where()
protected wherePending ( ) : boolean
return boolean
    protected function wherePending()
    {
        $operator = array('=' => '==', '!=' => '!=', '>' => '>', '<' => '<', '>=' => '>=', '<=' => '<=', 'and' => '&&', 'or' => '||');
        $this->data = array_filter($this->data, function ($row) use($operator) {
            $clause = '';
            $result = true;
            foreach ($this->pending['where'] as $key => $condition) {
                extract($condition);
                if (is_array($value) && $op == 'IN') {
                    $value = in_array($row->{$field}, $value) ? 1 : 0;
                    $op = '==';
                    $field = 1;
                } elseif (!is_array($value) && in_array($op, array('LIKE', 'like'))) {
                    $regex = "/^" . str_replace('%', '(.*?)', preg_quote($value)) . "\$/si";
                    $value = preg_match($regex, $row->{$field});
                    $op = '==';
                    $field = 1;
                } elseif (!is_array($value) && $op != 'IN') {
                    $value = is_string($value) ? '\'' . mb_strtolower($value) . '\'' : $value;
                    $op = $operator[$op];
                    $field = is_string($row->{$field}) ? 'mb_strtolower($row->' . $field . ')' : '$row->' . $field;
                }
                $type = !$key ? null : $operator[$type];
                $query = array($type, $field, $op, $value);
                $clause .= implode(' ', $query) . ' ';
                eval('$result = ' . $clause . ';');
            }
            return $result;
        });
    }