1 | <?php |
||
7 | class Paginator |
||
8 | { |
||
9 | private $options; |
||
10 | private $numberOfRecords; |
||
11 | private $numberOfRecordsOnPage; |
||
12 | |||
13 | public function __construct(GridContext $options, int $numberOfRecordsOnPage, int $numberOfRecords = null) |
||
19 | |||
20 | public function getPageSize(): int |
||
24 | |||
25 | public function getCurrentPage(): int |
||
29 | |||
30 | public function getNumberOfRecords() |
||
34 | |||
35 | public function getNumberOfPages(): int |
||
36 | { |
||
37 | if (null === $this->numberOfRecords) { |
||
38 | throw new \RuntimeException( |
||
39 | 'Cannot determine the last page when the total number of ' . |
||
40 | 'records has not been provided.' |
||
41 | ); |
||
42 | } |
||
43 | |||
44 | return (int) ceil($this->getNumberOfRecords() / $this->getPageSize()); |
||
45 | } |
||
46 | |||
47 | public function isLastPage(): bool |
||
55 | |||
56 | public function getUrlParametersForPage($page = null) |
||
62 | } |
||
63 |