| Total Complexity | 4 |
| Total Lines | 39 |
| Duplicated Lines | 0 % |
| Coverage | 88.24% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 19 | final class PaginationWalkStrategy implements WalkStrategyInterface |
||
| 20 | { |
||
| 21 | /** |
||
| 22 | * {@inheritdoc} |
||
| 23 | */ |
||
| 24 | 10 | public function initialize(ReadCommandInterface $query, int $chunkSize, int $startPage): WalkCursor |
|
| 25 | { |
||
| 26 | 10 | if (!$query instanceof Limitable) { |
|
| 27 | throw new InvalidArgumentException('The query must be an instance of '.Limitable::class); |
||
| 28 | } |
||
| 29 | |||
| 30 | 10 | $query = clone $query; |
|
| 31 | 10 | $cursor = new WalkCursor($query); |
|
| 32 | |||
| 33 | 10 | $cursor->cursor = ($startPage - 1) * $chunkSize; |
|
| 34 | 10 | $query->limit($chunkSize); |
|
| 35 | |||
| 36 | 10 | return $cursor; |
|
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * {@inheritdoc} |
||
| 41 | */ |
||
| 42 | #[ReadOperation] |
||
| 58 | } |
||
| 59 | } |
||
| 60 |