public function createResultCollection($data = [], $method = 'create')
    {
        $collection = new ResultCollection();

        if (null === $data) {
            return $collection;
        }

        if (array_key_exists('page', $data)) {
            $collection->setPage($data['page']);
        }

        if (array_key_exists('total_pages', $data)) {
            $collection->setTotalPages($data['total_pages']);
        }

        if (array_key_exists('total_results', $data)) {
            $collection->setTotalResults($data['total_results']);
        }

        if (array_key_exists('results', $data)) {
            $data = $data['results'];
        }

        foreach ($data as $item) {
            $collection->add(null, $this->$method($item));
        }

        return $collection;
    }
public function createResultCollection($data = [], $method = 'create')
    {
        $collection = new ResultCollection();

        if (null === $data) {
            return $collection;
        }

        if (array_key_exists('page', $data)) {
            $collection->setPage($data['page']);
        }

        if (array_key_exists('total_pages', $data)) {
            $collection->setTotalPages($data['total_pages']);
        }

        if (array_key_exists('total_results', $data)) {
            $collection->setTotalResults($data['total_results']);
        }

        if (array_key_exists('results', $data)) {
            $data = $data['results'];
        }

        foreach ($data as $item) {
            $collection->add(null, $this->$method($item));
        }

        return $collection;
    }
public function createResultCollection ( $ data = [ ] , $ method = 'create' ) { $ collection = new ResultCollection ( ) ; if ( null === $ data ) { return $ collection ; } if ( array_key_exists ( 'page' , $ data ) ) { $ collection -> setPage ( $ data [ 'page' ] ) ; } if ( array_key_exists ( 'total_pages' , $ data ) ) { $ collection -> setTotalPages ( $ data [ 'total_pages' ] ) ; } if ( array_key_exists ( 'total_results' , $ data ) ) { $ collection -> setTotalResults ( $ data [ 'total_results' ] ) ; } if ( array_key_exists ( 'results' , $ data ) ) { $ data = $ data [ 'results' ] ; } foreach ( $ data as $ item ) { $ collection -> add ( null , $ this -> $ method ( $ item ) ) ; } return $ collection ; }
Create a result collection

@param  array            $data
@param  string           $method
@return ResultCollection
Create a result collection