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