src/Dlin/Zendesk/Client/BaseClient.php
public function getCollection($end_point, $collectionName,  $page = 1, $per_page = 100, $sort_by = null, $sort_order = 'asc')
    {
        $end_point = strtolower($end_point);
        if (strpos($end_point, 'http') !== 0) {
            $end_point = $this->api->getApiUrl() . $end_point;
        }

        $request = $this->api->get($end_point);
        $query = $request->getQuery()->set('page', $page)->set('per_page', $per_page);
        if ($sort_by) {
            $query->set('sort_by', $sort_by)->set('sort_order', $sort_order == 'asc' ? 'asc' : 'desc');
        }


        $response = $this->processRequest($request);


        $values = $response->json();

        $result = new PaginatedResult();
        $result->setClient($this);

        if (array_key_exists('count', $values)) {
            $result->setCount($values['count']);
        }



        /*
        if (array_key_exists('next_page', $values)) {
            $result->setNextPage($values['next_page']); //Note: the api skips the per_page parameter, making it useless
        }
        if (array_key_exists('previous_page', $values)) {
            $result->setPreviousPage($values['previous_page']); //Note: the api always return null
        }
        */

        $result->setCurrentPage($page);
        $result->setPerPage($per_page);
        $result->setEndPoint($end_point);

        $type = $this->getType();

        if (array_key_exists($collectionName, $values) && is_array($values[$collectionName])) {
            foreach ($values[$collectionName] as $value) {
                $entity = new $type();
                $this->manage($entity);
                $result[] = $entity->fromArray($value);
            }
        }
        return $result;


    }
public function getCollection($end_point, $collectionName,  $page = 1, $per_page = 100, $sort_by = null, $sort_order = 'asc')
    {
        $end_point = strtolower($end_point);
        if (strpos($end_point, 'http') !== 0) {
            $end_point = $this->api->getApiUrl() . $end_point;
        }

        $request = $this->api->get($end_point);
        $query = $request->getQuery()->set('page', $page)->set('per_page', $per_page);
        if ($sort_by) {
            $query->set('sort_by', $sort_by)->set('sort_order', $sort_order == 'asc' ? 'asc' : 'desc');
        }


        $response = $this->processRequest($request);


        $values = $response->json();

        $result = new PaginatedResult();
        $result->setClient($this);

        if (array_key_exists('count', $values)) {
            $result->setCount($values['count']);
        }



        /*
        if (array_key_exists('next_page', $values)) {
            $result->setNextPage($values['next_page']); //Note: the api skips the per_page parameter, making it useless
        }
        if (array_key_exists('previous_page', $values)) {
            $result->setPreviousPage($values['previous_page']); //Note: the api always return null
        }
        */

        $result->setCurrentPage($page);
        $result->setPerPage($per_page);
        $result->setEndPoint($end_point);

        $type = $this->getType();

        if (array_key_exists($collectionName, $values) && is_array($values[$collectionName])) {
            foreach ($values[$collectionName] as $value) {
                $entity = new $type();
                $this->manage($entity);
                $result[] = $entity->fromArray($value);
            }
        }
        return $result;


    }
Generic function for getting a collection of entities

@param $end_point
@param int $page
@param int $per_page
@param null $sort_by
@param string $sort_order
@return \Dlin\Zendesk\Result\PaginatedResult