| Conditions | 4 |
| Paths | 4 |
| Total Lines | 15 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 16 | public function chunkIterator(int $batchSize, string $key): \Generator |
||
| 17 | { |
||
| 18 | $start = \strpos($key, $this->prefixKey()); |
||
| 19 | if ($start !== false) { |
||
| 20 | $key = \substr($key, $start); |
||
| 21 | } |
||
| 22 | |||
| 23 | do { |
||
| 24 | $bulk = Redis::lrange($key, 0, \max($batchSize - 1, 0)); |
||
| 25 | $count = \count($bulk); |
||
| 26 | if ($count) { |
||
| 27 | yield $bulk; |
||
| 28 | Redis::ltrim($key, $count, -1); |
||
| 29 | } |
||
| 30 | } while ($count >= $batchSize); |
||
| 31 | } |
||
| 68 |