Total Complexity | 6 |
Total Lines | 34 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
7 | class GridSourcePager extends Pager |
||
8 | { |
||
9 | private $gridSource; |
||
10 | private $totalPages; |
||
|
|||
11 | |||
12 | public function __construct(GridSourceInterface $gridSource) |
||
13 | { |
||
14 | $this->gridSource = $gridSource; |
||
15 | } |
||
16 | |||
17 | public function getCurrentPage() |
||
18 | { |
||
19 | $limit = $this->gridSource->getLimit(); |
||
20 | $offset = $this->gridSource->getOffset(); |
||
21 | |||
22 | if (!$limit) { |
||
23 | return $offset; |
||
24 | } |
||
25 | |||
26 | return ceil(($offset / $limit) + 1); |
||
27 | } |
||
28 | |||
29 | public function getTotalPages() |
||
30 | { |
||
31 | $limit = $this->gridSource->getLimit(); |
||
32 | if (!$limit) { |
||
33 | return $this->gridSource->getCount(); |
||
34 | } |
||
35 | |||
36 | return ceil($this->gridSource->getCount() / $limit); |
||
37 | } |
||
38 | |||
39 | public function getRange($delta) |
||
41 | } |
||
42 | } |
||
43 |