1 | <?php |
||
20 | class BatchingIterator implements \Iterator { |
||
21 | |||
22 | /** |
||
23 | * @var BatchingFetcher |
||
24 | */ |
||
25 | private $fetcher; |
||
26 | |||
27 | /** |
||
28 | * @var int |
||
29 | */ |
||
30 | private $maxBatchSize = 10; |
||
31 | |||
32 | /** |
||
33 | * @var mixed|null |
||
34 | */ |
||
35 | private $current = null; |
||
36 | |||
37 | /** |
||
38 | * @var mixed[] |
||
39 | */ |
||
40 | private $currentBatch = []; |
||
41 | |||
42 | /** |
||
43 | * @var int |
||
44 | */ |
||
45 | private $key; |
||
46 | |||
47 | 12 | public function __construct( BatchingFetcher $fetcher ) { |
|
50 | |||
51 | /** |
||
52 | * @param int $maxBatchSize |
||
53 | * |
||
54 | * @throws InvalidArgumentException |
||
55 | */ |
||
56 | 9 | public function setMaxBatchSize( int $maxBatchSize ) { |
|
63 | |||
64 | /** |
||
65 | * Returns a value of the type returned by the BatchingFetcher, |
||
66 | * or null if there are no further values. |
||
67 | * |
||
68 | * @return mixed|null |
||
69 | */ |
||
70 | 7 | public function current() { |
|
73 | |||
74 | 9 | public function next() { |
|
85 | |||
86 | 9 | private function nextValueFromNewBatch() { |
|
96 | |||
97 | 7 | public function key(): int { |
|
100 | |||
101 | 8 | public function valid(): bool { |
|
104 | |||
105 | 9 | public function rewind() { |
|
110 | |||
111 | } |
||
112 |