| @@ 1284-1304 (lines=21) @@ | ||
| 1281 | yield $values; |
|
| 1282 | } |
|
| 1283 | }; |
|
| 1284 | } else { |
|
| 1285 | $generator = function () use ($size) { |
|
| 1286 | $values = []; |
|
| 1287 | $tmpCounter = 0; |
|
| 1288 | foreach ($this->getGenerator() as $key => $value) { |
|
| 1289 | ++$tmpCounter; |
|
| 1290 | ||
| 1291 | $values[] = $value; |
|
| 1292 | if ($tmpCounter === $size) { |
|
| 1293 | yield $values; |
|
| 1294 | ||
| 1295 | $values = []; |
|
| 1296 | $tmpCounter = 0; |
|
| 1297 | } |
|
| 1298 | } |
|
| 1299 | ||
| 1300 | if ($values !== []) { |
|
| 1301 | yield $values; |
|
| 1302 | } |
|
| 1303 | }; |
|
| 1304 | } |
|
| 1305 | ||
| 1306 | return static::create( |
|
| 1307 | $generator, |
|
| @@ 6391-6414 (lines=24) @@ | ||
| 6388 | yield $carry; |
|
| 6389 | } |
|
| 6390 | }; |
|
| 6391 | } else { |
|
| 6392 | $generator = function () use ($numberOfPieces) { |
|
| 6393 | $carry = []; |
|
| 6394 | $i = 1; |
|
| 6395 | foreach ($this->getGenerator() as $key => $value) { |
|
| 6396 | $carry[] = $value; |
|
| 6397 | ||
| 6398 | if ($i % $numberOfPieces !== 0) { |
|
| 6399 | ++$i; |
|
| 6400 | ||
| 6401 | continue; |
|
| 6402 | } |
|
| 6403 | ||
| 6404 | yield $carry; |
|
| 6405 | ||
| 6406 | $carry = []; |
|
| 6407 | $i = 1; |
|
| 6408 | } |
|
| 6409 | ||
| 6410 | if ($carry !== []) { |
|
| 6411 | yield $carry; |
|
| 6412 | } |
|
| 6413 | }; |
|
| 6414 | } |
|
| 6415 | ||
| 6416 | return static::create( |
|
| 6417 | $generator, |
|