@@ -36,24 +36,24 @@ discard block |
||
36 | 36 | } |
37 | 37 | |
38 | 38 | private function init() { |
39 | - $pos = 'full'; |
|
39 | + $pos = 'full'; |
|
40 | 40 | |
41 | - switch ($this->page) { |
|
42 | - case (($this->page - $this->length) < 3): |
|
43 | - $pos = 'noLeftDots'; |
|
44 | - break; |
|
45 | - case (($this->page - $this->length) >= 3 && ($this->totalPages - $this->page - $this->length) > 1): |
|
46 | - $pos = 'center'; |
|
47 | - break; |
|
48 | - case (abs($this->totalPages - $this->page - $this->length) >= 0): |
|
49 | - $pos = 'noRightDots'; |
|
50 | - break; |
|
51 | - case ($this->totalPages < 7): |
|
52 | - $pos = 'full'; |
|
53 | - break; |
|
54 | - } |
|
41 | + switch ($this->page) { |
|
42 | + case (($this->page - $this->length) < 3): |
|
43 | + $pos = 'noLeftDots'; |
|
44 | + break; |
|
45 | + case (($this->page - $this->length) >= 3 && ($this->totalPages - $this->page - $this->length) > 1): |
|
46 | + $pos = 'center'; |
|
47 | + break; |
|
48 | + case (abs($this->totalPages - $this->page - $this->length) >= 0): |
|
49 | + $pos = 'noRightDots'; |
|
50 | + break; |
|
51 | + case ($this->totalPages < 7): |
|
52 | + $pos = 'full'; |
|
53 | + break; |
|
54 | + } |
|
55 | 55 | |
56 | - return $pos; |
|
56 | + return $pos; |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | /** |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | } |
97 | 97 | |
98 | 98 | if ($this->page > 3) { |
99 | - $result['second'] = 2; |
|
100 | - } |
|
99 | + $result['second'] = 2; |
|
100 | + } |
|
101 | 101 | |
102 | 102 | return $this->uiKeys ? $result : []; |
103 | 103 | } |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | } |
120 | 120 | |
121 | 121 | if ($this->totalPages - $this->page + $this->length > 3) { |
122 | - $result['preLast'] = $this->totalPages - 1; |
|
122 | + $result['preLast'] = $this->totalPages - 1; |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | return $this->uiKeys ? $result : []; |
@@ -133,21 +133,21 @@ discard block |
||
133 | 133 | $result = []; |
134 | 134 | $for = []; |
135 | 135 | |
136 | - if ($this->page - $this->length > 1) { |
|
137 | - $result[] = 1; |
|
138 | - } |
|
136 | + if ($this->page - $this->length > 1) { |
|
137 | + $result[] = 1; |
|
138 | + } |
|
139 | 139 | |
140 | 140 | if ($this->pos !== 'noLeftDots') { |
141 | - if ($this->uiKeys) { |
|
142 | - $result['leftDots'] = '...'; |
|
143 | - } else { |
|
144 | - $result[] = '...'; |
|
145 | - } |
|
141 | + if ($this->uiKeys) { |
|
142 | + $result['leftDots'] = '...'; |
|
143 | + } else { |
|
144 | + $result[] = '...'; |
|
145 | + } |
|
146 | 146 | } |
147 | 147 | |
148 | - foreach (range($this->page - 1, $this->page - $this->length) as $value) { |
|
148 | + foreach (range($this->page - 1, $this->page - $this->length) as $value) { |
|
149 | 149 | if ($value > 0) { |
150 | - $for[] = $value; |
|
150 | + $for[] = $value; |
|
151 | 151 | } |
152 | 152 | } |
153 | 153 | |
@@ -161,22 +161,22 @@ discard block |
||
161 | 161 | { |
162 | 162 | $result = []; |
163 | 163 | |
164 | - foreach (range($this->page + 1, $this->page + $this->length) as $value) { |
|
165 | - if ($value <= $this->totalPages) { |
|
166 | - $result[] = $value; |
|
167 | - } |
|
168 | - } |
|
164 | + foreach (range($this->page + 1, $this->page + $this->length) as $value) { |
|
165 | + if ($value <= $this->totalPages) { |
|
166 | + $result[] = $value; |
|
167 | + } |
|
168 | + } |
|
169 | 169 | |
170 | 170 | if ($this->pos !== 'noRightDots') { |
171 | - if ($this->uiKeys) { |
|
172 | - $result['rightDots'] = '...'; |
|
173 | - } else { |
|
174 | - $result[] = '...'; |
|
175 | - } |
|
171 | + if ($this->uiKeys) { |
|
172 | + $result['rightDots'] = '...'; |
|
173 | + } else { |
|
174 | + $result[] = '...'; |
|
175 | + } |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | if ($this->totalPages - $this->page - $this->length > 0) { |
179 | - $result[] = $this->totalPages; |
|
179 | + $result[] = $this->totalPages; |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | return $result; |
@@ -184,13 +184,13 @@ discard block |
||
184 | 184 | |
185 | 185 | private function getCurrent() |
186 | 186 | { |
187 | - if ($this->uiKeys) { |
|
188 | - $result['current'] = $this->page; |
|
189 | - } else { |
|
190 | - $result[] = $this->page; |
|
191 | - } |
|
187 | + if ($this->uiKeys) { |
|
188 | + $result['current'] = $this->page; |
|
189 | + } else { |
|
190 | + $result[] = $this->page; |
|
191 | + } |
|
192 | 192 | |
193 | - return $result; |
|
193 | + return $result; |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | /** |
@@ -26,7 +26,7 @@ |
||
26 | 26 | */ |
27 | 27 | public function __construct(int $page, int $limit, int $total, int $length = 3, bool $uiKeys = true) |
28 | 28 | { |
29 | - $this->totalPages = (int)ceil($total / $limit); |
|
29 | + $this->totalPages = (int) ceil($total / $limit); |
|
30 | 30 | $this->page = $page > 1 ? ($page > $this->totalPages ? 1 : $page) : 1; |
31 | 31 | $this->limit = $limit > 0 ? $limit : 10; |
32 | 32 | $this->total = $total; |