1 | <?php |
||
7 | class ChunkListener extends Listener |
||
8 | { |
||
9 | /** |
||
10 | * The size of the chunk. |
||
11 | * |
||
12 | * @var int |
||
13 | */ |
||
14 | protected $size; |
||
15 | |||
16 | /** |
||
17 | * The callback processing the chunk. |
||
18 | * |
||
19 | * @var callable |
||
20 | */ |
||
21 | protected $callback; |
||
22 | |||
23 | /** |
||
24 | * The chunk of objects. |
||
25 | * |
||
26 | * @var array |
||
27 | */ |
||
28 | protected $chunk; |
||
29 | |||
30 | /** |
||
31 | * @param int $size size of the chunk to collect before processing |
||
32 | * @param callback|callable $callback callback for parsed collection item |
||
33 | * @param bool $assoc When true, returned objects will be converted into associative arrays |
||
34 | */ |
||
35 | public function __construct(int $size, callable $callback, bool $assoc = true) |
||
42 | |||
43 | public function endObject(): void |
||
58 | |||
59 | public function endDocument(): void |
||
65 | |||
66 | protected function processChunk(): void |
||
76 | } |
||
77 |