Total Complexity | 10 |
Total Lines | 63 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
6 | class PaginatedCollection extends Collection |
||
7 | { |
||
8 | protected $totalCount; |
||
9 | protected $perPage; |
||
10 | protected $currentPage; |
||
11 | |||
12 | public function __construct(array $elements, int $totalCount, int $perPage, int $currentPage) |
||
13 | { |
||
14 | parent::__construct($elements); |
||
15 | $this->totalCount = $totalCount; |
||
16 | $this->perPage = $perPage; |
||
17 | $this->currentPage = $currentPage; |
||
18 | } |
||
19 | |||
20 | /** |
||
21 | * @return mixed |
||
22 | */ |
||
23 | public function getTotalCount() |
||
24 | { |
||
25 | return $this->totalCount; |
||
26 | } |
||
27 | |||
28 | /** |
||
29 | * @return mixed |
||
30 | */ |
||
31 | public function getPerPage() |
||
32 | { |
||
33 | return $this->perPage; |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * @return mixed |
||
38 | */ |
||
39 | public function getCurrentPage() |
||
40 | { |
||
41 | return $this->currentPage; |
||
42 | } |
||
43 | |||
44 | public function getTotalPages() |
||
45 | { |
||
46 | if ($this->perPage < 1) { |
||
47 | return 0; |
||
48 | } |
||
49 | |||
50 | return ceil($this->totalCount / $this->perPage); |
||
51 | } |
||
52 | |||
53 | public function getPageStart() |
||
60 | } |
||
61 | |||
62 | public function getPageEnd() |
||
69 | } |
||
70 | } |
||
71 |