$documentValue) { $batch[$documentName] = $documentValue; if (++$i == $size) { yield $batch; $i = 0; $batch = []; } } if (count($batch) > 0) { yield $batch; } } }