Conditions | 3 |
Paths | 4 |
Total Lines | 18 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
23 | public function paged(...$input) |
||
24 | { |
||
25 | list($page, $size) = |
||
26 | count($input) === 1 && is_object($input[0]) |
||
27 | ? $this->import($input[0]) |
||
28 | : [$input[0] ?? 1, $input[1] ?? $this->pSize] |
||
29 | ; |
||
30 | |||
31 | $total = yield $this->count(); |
||
32 | |||
33 | $last = ceil($total / $size); |
||
34 | |||
35 | $next = min($page + 1, $last); |
||
36 | $prev = max($page - 1, 1); |
||
37 | |||
38 | $this->limit(($page - 1) * $size, $size); |
||
39 | |||
40 | return new Pagination($total, $size, $prev, $page, $next, $last, yield $this->list()); |
||
41 | } |
||
62 |