protected function makeWhere(Condition $condition, array $data = NULL)
    {
        $data = $data === NULL
            ? $this->data
            : $data;

        return array_filter($data, function ($row) use ($condition) {
            if ($condition->callback) {
                return call_user_func_array($condition->callback, [$condition->value, $row]);
            }

            $i = 0;
            $results = [];
            foreach ($condition->column as $column) {
                if (Condition::isOperator($column)) {
                    $results[] = " $column ";

                } else {
                    $i = count($condition->condition) > 1 ? $i : 0;
                    $results[] = (int) $this->compare(
                        $row[$column],
                        $condition->condition[$i],
                        isset($condition->value[$i]) ? $condition->value[$i] : NULL
                    );

                    $i++;
                }
            }

            $result = implode('', $results);
            return count($condition->column) === 1
                ? (bool) $result
                : eval("return $result;"); // QUESTION: How to remove this eval? hmmm?
        });
    }
protected function makeWhere(Condition $condition, array $data = NULL)
    {
        $data = $data === NULL
            ? $this->data
            : $data;

        return array_filter($data, function ($row) use ($condition) {
            if ($condition->callback) {
                return call_user_func_array($condition->callback, [$condition->value, $row]);
            }

            $i = 0;
            $results = [];
            foreach ($condition->column as $column) {
                if (Condition::isOperator($column)) {
                    $results[] = " $column ";

                } else {
                    $i = count($condition->condition) > 1 ? $i : 0;
                    $results[] = (int) $this->compare(
                        $row[$column],
                        $condition->condition[$i],
                        isset($condition->value[$i]) ? $condition->value[$i] : NULL
                    );

                    $i++;
                }
            }

            $result = implode('', $results);
            return count($condition->column) === 1
                ? (bool) $result
                : eval("return $result;"); // QUESTION: How to remove this eval? hmmm?
        });
    }
protected function makeWhere ( Condition $ condition , array $ data = NULL ) { $ data = $ data === NULL ? $ this -> data : $ data ; return array_filter ( $ data , function ( $ row ) use ( $ condition ) { if ( $ condition -> callback ) { return call_user_func_array ( $ condition -> callback , [ $ condition -> value , $ row ] ) ; } $ i = 0 ; $ results = [ ] ; foreach ( $ condition -> column as $ column ) { if ( Condition :: isOperator ( $ column ) ) { $ results [ ] = " $column " ; } else { $ i = count ( $ condition -> condition ) > 1 ? $ i : 0 ; $ results [ ] = ( int ) $ this -> compare ( $ row [ $ column ] , $ condition -> condition [ $ i ] , isset ( $ condition -> value [ $ i ] ) ? $ condition -> value [ $ i ] : NULL ) ; $ i ++ ; } } $ result = implode ( '' , $ results ) ; return count ( $ condition -> column ) === 1 ? ( bool ) $ result : eval ( "return $result;" ) ; // QUESTION: How to remove this eval? hmmm? } ) ; }
This method needs tests!
@param Condition $condition
@param array $data
@return array
This method needs tests!