protected function buildResult(ConditionGroup $conditions, array $sorting, $keys=[], $page=null, $perPage=null)
    {

        $matcher = $this->createMatcher($conditions);
        $shouldBreak = $page && $perPage && !$sorting;

        $offset = $shouldBreak ? ($page-1)*$perPage : 0;
        $limit = $shouldBreak ? $perPage : null;

        $filtered = $this->filterData($matcher, $offset, $limit);

        if ($shouldBreak) {
            // Create a "not length aware" paginator here
            $paginator = new Paginator($page, $perPage, $this);
            $paginator->setResult($filtered);
            return $paginator;
        }

        if ($sorting) {
            $this->sortResult($filtered, $sorting);
        }

        if (!$page || !$perPage) {
            return $filtered;
        }

        $paginator = new Paginator($page, $perPage, $this);

        return $paginator->setResult($paginator->slice($filtered), count($filtered));

    }
protected function buildResult(ConditionGroup $conditions, array $sorting, $keys=[], $page=null, $perPage=null)
    {

        $matcher = $this->createMatcher($conditions);
        $shouldBreak = $page && $perPage && !$sorting;

        $offset = $shouldBreak ? ($page-1)*$perPage : 0;
        $limit = $shouldBreak ? $perPage : null;

        $filtered = $this->filterData($matcher, $offset, $limit);

        if ($shouldBreak) {
            // Create a "not length aware" paginator here
            $paginator = new Paginator($page, $perPage, $this);
            $paginator->setResult($filtered);
            return $paginator;
        }

        if ($sorting) {
            $this->sortResult($filtered, $sorting);
        }

        if (!$page || !$perPage) {
            return $filtered;
        }

        $paginator = new Paginator($page, $perPage, $this);

        return $paginator->setResult($paginator->slice($filtered), count($filtered));

    }
protected function buildResult ( ConditionGroup $ conditions , array $ sorting , $ keys = [ ] , $ page = null , $ perPage = null ) { $ matcher = $ this -> createMatcher ( $ conditions ) ; $ shouldBreak = $ page && $ perPage && ! $ sorting ; $ offset = $ shouldBreak ? ( $ page - 1 ) * $ perPage : 0 ; $ limit = $ shouldBreak ? $ perPage : null ; $ filtered = $ this -> filterData ( $ matcher , $ offset , $ limit ) ; if ( $ shouldBreak ) { // Create a "not length aware" paginator here $ paginator = new Paginator ( $ page , $ perPage , $ this ) ; $ paginator -> setResult ( $ filtered ) ; return $ paginator ; } if ( $ sorting ) { $ this -> sortResult ( $ filtered , $ sorting ) ; } if ( ! $ page || ! $ perPage ) { return $ filtered ; } $ paginator = new Paginator ( $ page , $ perPage , $ this ) ; return $ paginator -> setResult ( $ paginator -> slice ( $ filtered ) , count ( $ filtered ) ) ; }
Build the result array by filtering it and then sorting it.

@param ConditionGroup $conditions
@param array          $sorting
@param array          $keys (optional)
@param int            $page (optional)
@param int            $perPage (optional)

@return array|Paginator
Build the result array by filtering it and then sorting it .