private function getLinkHeaderValues(string $url, PaginationInfo $paginationInfo, int $resultPageSize) : array { $headerBuilder = new LinkHeaderBuilder(); $linkHeaderValues = []; if ($resultPageSize === $paginationInfo->getPerPage()) { $linkHeaderValues[] = $headerBuilder->buildLinkHeader('next', $url, ['page' => $paginationInfo->getPage() + 1, 'per_page' => $paginationInfo->getPerPage()]); } if ($paginationInfo->getPage() !== 1) { $linkHeaderValues[] = $headerBuilder->buildLinkHeader('first', $url, ['page' => 1, 'per_page' => $paginationInfo->getPerPage()]); } if ($paginationInfo->getPage() !== 1) { $linkHeaderValues[] = $headerBuilder->buildLinkHeader('previous', $url, ['page' => $paginationInfo->getPage() - 1, 'per_page' => $paginationInfo->getPerPage()]); } return $linkHeaderValues; }
public function testWithQueryStringThatShouldBeEscaped() { $this->assertSame('<http://localhost/properties?page=%3F%25%21&per_page=%26%5C>; rel="next"', $this->headerBuilder->buildLinkHeader('next', 'http://localhost/properties', ['page' => '?%!', 'per_page' => '&\\'])); }