zendesk/zendesk_api_client_php

View on GitHub
src/Zendesk/API/Traits/Utility/Pagination/ObpStrategy.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

namespace Zendesk\API\Traits\Utility\Pagination;

/**
 * Offset Based Pagination
 * Used in paginationStrategyClass
 */
class ObpStrategy extends AbstractStrategy
{
    private $pageNumber = 0;

    public function page($getPageFn)
    {
        ++$this->pageNumber;
        $response = $getPageFn();

        return $response->{$this->resourcesKey};
    }

    public function shouldGetPage($current_page) {
        return $this->pageNumber == 0 || count($current_page) == 0;
    }
}