*/ trait Pagination { abstract protected function httpGet(string $path, array $parameters = [], array $requestHeaders = []): ResponseInterface; abstract protected function hydrateResponse(ResponseInterface $response, string $className); public function nextPage(PagingProvider $response): ?PagingProvider { return $this->getPaginationUrl($response->getNextUrl(), get_class($response)); } public function previousPage(PagingProvider $response): ?PagingProvider { return $this->getPaginationUrl($response->getPreviousUrl(), get_class($response)); } public function firstPage(PagingProvider $response): ?PagingProvider { return $this->getPaginationUrl($response->getFirstUrl(), get_class($response)); } public function lastPage(PagingProvider $response): ?PagingProvider { return $this->getPaginationUrl($response->getLastUrl(), get_class($response)); } private function getPaginationUrl(string $url, string $class): ?PagingProvider { Assert::stringNotEmpty($class); if (empty($url)) { return null; } $response = $this->httpGet($url); return $this->hydrateResponse($response, $class); } }