Total Complexity | 6 |
Total Lines | 55 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
6 | abstract class Paginator |
||
7 | { |
||
8 | /** @var int */ |
||
9 | protected $limit; |
||
10 | |||
11 | /** @var int */ |
||
12 | protected $offset; |
||
13 | |||
14 | /** @var array */ |
||
15 | protected $meta = []; |
||
16 | |||
17 | 6 | public function __construct(?int $limit, int $offset) |
|
18 | { |
||
19 | 6 | $this->limit = $limit; |
|
20 | 6 | $this->offset = $offset; |
|
21 | 6 | } |
|
22 | |||
23 | /** |
||
24 | * @param string $name |
||
25 | * @param mixed $value also a callable which will be resolved when meta data would be needed; see resolveMeta() |
||
26 | */ |
||
27 | 3 | public function addMeta(string $name, $value): void |
|
28 | { |
||
29 | 3 | $this->meta[$name] = $value; |
|
30 | 3 | } |
|
31 | |||
32 | 2 | public function getResults(): array |
|
33 | { |
||
34 | 2 | return $this->findAll(); |
|
35 | } |
||
36 | |||
37 | 4 | public function getMeta(): array |
|
44 | } |
||
45 | |||
46 | private function resolveMeta(): array |
||
56 | } |
||
57 | |||
58 | abstract protected function findAll(): array; |
||
59 | |||
60 | abstract protected function getTotal(): int; |
||
61 | } |
||
62 |