1 | <?php |
||
20 | class PagerAwareViewData extends ViewData |
||
21 | { |
||
22 | use OptionsAwareTrait; |
||
23 | |||
24 | /** |
||
25 | * @var int Current page. |
||
26 | */ |
||
27 | private $currentPage = 1; |
||
28 | |||
29 | /** |
||
30 | * @var int Total amount of items to show. |
||
31 | */ |
||
32 | private $totalItems = 1; |
||
33 | |||
34 | /** |
||
35 | * @var int Maximum pages to show. |
||
36 | */ |
||
37 | private $maxPages = 10; |
||
38 | |||
39 | /** |
||
40 | * @var int Maximum items show per page. |
||
41 | */ |
||
42 | private $itemsPerPage = 12; |
||
43 | |||
44 | /** |
||
45 | * @var Number of pages to show. |
||
46 | */ |
||
47 | private $numPages; |
||
48 | |||
49 | /** |
||
50 | * Initializes data for pagination. |
||
51 | * |
||
52 | * @param $totalItems |
||
53 | * @param $currentPage |
||
54 | * @param int $itemsPerPage |
||
55 | * @param int $maxPages |
||
56 | */ |
||
57 | public function setData($totalItems, $currentPage, $itemsPerPage = 12, $maxPages = 10) |
||
70 | |||
71 | /** |
||
72 | * {@inheritdoc} |
||
73 | */ |
||
74 | public function getSerializableData() |
||
90 | |||
91 | /** |
||
92 | * Get previous page number. |
||
93 | * |
||
94 | * @return int|null |
||
95 | */ |
||
96 | public function getPreviousPage() |
||
104 | |||
105 | /** |
||
106 | * Returns current page number. |
||
107 | * |
||
108 | * @return int |
||
109 | */ |
||
110 | public function getCurrentPage() |
||
114 | |||
115 | /** |
||
116 | * Get next page number. |
||
117 | * |
||
118 | * @return int|null |
||
119 | */ |
||
120 | public function getNextPage() |
||
128 | |||
129 | /** |
||
130 | * Returns the last page number. |
||
131 | * |
||
132 | * @return int |
||
133 | */ |
||
134 | public function getLastPage() |
||
138 | |||
139 | /** |
||
140 | * Returns true if the current page is first. |
||
141 | * |
||
142 | * @return bool |
||
143 | */ |
||
144 | public function isFirstPage() |
||
148 | |||
149 | /** |
||
150 | * Returns the first page number. |
||
151 | * |
||
152 | * @return int |
||
153 | */ |
||
154 | public function getFirstPage() |
||
158 | |||
159 | /** |
||
160 | * Returns true if the current page is last. |
||
161 | * |
||
162 | * @return bool |
||
163 | */ |
||
164 | public function isLastPage() |
||
168 | |||
169 | /** |
||
170 | * Generates a page list. |
||
171 | * |
||
172 | * @return array The page list. |
||
173 | */ |
||
174 | public function getPages() |
||
208 | } |
||
209 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.