| Total Complexity | 7 |
| Total Lines | 43 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | final class ArrayPage implements Page |
||
| 8 | { |
||
| 9 | private array $slice; |
||
| 10 | private int $offset; |
||
| 11 | private int $limit; |
||
| 12 | private int $totalCount; |
||
| 13 | |||
| 14 | 22 | public function __construct(array $slice, int $offset, int $limit, int $totalCount) |
|
| 15 | { |
||
| 16 | 22 | $this->slice = $slice; |
|
| 17 | 22 | $this->offset = $offset; |
|
| 18 | 22 | $this->limit = $limit; |
|
| 19 | 22 | $this->totalCount = $totalCount; |
|
| 20 | 22 | } |
|
| 21 | |||
| 22 | 4 | public function currentOffset(): int |
|
| 23 | { |
||
| 24 | 4 | return $this->offset; |
|
| 25 | } |
||
| 26 | |||
| 27 | 4 | public function currentPage(): int |
|
| 28 | { |
||
| 29 | 4 | return \floor($this->offset / $this->limit) + 1; |
|
|
|
|||
| 30 | } |
||
| 31 | |||
| 32 | 4 | public function currentLimit(): int |
|
| 33 | { |
||
| 34 | 4 | return $this->limit; |
|
| 35 | } |
||
| 36 | |||
| 37 | 16 | public function count(): int |
|
| 38 | { |
||
| 39 | 16 | return \count($this->slice); |
|
| 40 | } |
||
| 41 | |||
| 42 | 2 | public function totalCount(): int |
|
| 43 | { |
||
| 44 | 2 | return $this->totalCount; |
|
| 45 | } |
||
| 46 | |||
| 47 | 18 | public function getIterator(): \Traversable |
|
| 50 | } |
||
| 51 | } |
||
| 52 |