Total Complexity | 10 |
Total Lines | 65 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
8 | class Pagination |
||
9 | { |
||
10 | /** @var int */ |
||
11 | private $pageSize = 0; |
||
12 | |||
13 | /** @var int */ |
||
14 | private $current = 0; |
||
15 | |||
16 | /** @var int */ |
||
17 | private $count = 0; |
||
18 | |||
19 | /** |
||
20 | * @param int $pageSize |
||
21 | * @param int $currentPage |
||
22 | */ |
||
23 | public function setPage($pageSize, $currentPage) |
||
24 | { |
||
25 | $this->pageSize = $pageSize; |
||
26 | $this->current = max($currentPage, 1); |
||
27 | } |
||
28 | |||
29 | public function setCount($count) |
||
30 | { |
||
31 | $this->count = $count; |
||
32 | $this->current = min($this->last(), $this->current); |
||
33 | } |
||
34 | |||
35 | public function pageSize() |
||
36 | { |
||
37 | return $this->pageSize; |
||
38 | } |
||
39 | |||
40 | public function count() |
||
41 | { |
||
42 | return $this->count; |
||
43 | } |
||
44 | |||
45 | public function offset() |
||
46 | { |
||
47 | return $this->pageSize * ($this->current - 1); |
||
48 | } |
||
49 | |||
50 | public function current() |
||
51 | { |
||
52 | return $this->current; |
||
53 | } |
||
54 | |||
55 | public function first() |
||
56 | { |
||
57 | return 1; |
||
58 | } |
||
59 | |||
60 | public function last() |
||
63 | } |
||
64 | |||
65 | public function prev() |
||
66 | { |
||
67 | return max(1, $this->current - 1); |
||
68 | } |
||
69 | |||
70 | public function next() |
||
73 | } |
||
74 | } |
||
75 |