| @@ 1301-1321 (lines=21) @@ | ||
| 1298 | yield $values; |
|
| 1299 | } |
|
| 1300 | }; |
|
| 1301 | } else { |
|
| 1302 | $generator = function () use ($size) { |
|
| 1303 | $values = []; |
|
| 1304 | $tmpCounter = 0; |
|
| 1305 | foreach ($this->getGenerator() as $key => $value) { |
|
| 1306 | ++$tmpCounter; |
|
| 1307 | ||
| 1308 | $values[] = $value; |
|
| 1309 | if ($tmpCounter === $size) { |
|
| 1310 | yield $values; |
|
| 1311 | ||
| 1312 | $values = []; |
|
| 1313 | $tmpCounter = 0; |
|
| 1314 | } |
|
| 1315 | } |
|
| 1316 | ||
| 1317 | if ($values !== []) { |
|
| 1318 | yield $values; |
|
| 1319 | } |
|
| 1320 | }; |
|
| 1321 | } |
|
| 1322 | ||
| 1323 | return static::create( |
|
| 1324 | $generator, |
|
| @@ 6523-6546 (lines=24) @@ | ||
| 6520 | yield $carry; |
|
| 6521 | } |
|
| 6522 | }; |
|
| 6523 | } else { |
|
| 6524 | $generator = function () use ($numberOfPieces) { |
|
| 6525 | $carry = []; |
|
| 6526 | $i = 1; |
|
| 6527 | foreach ($this->getGenerator() as $key => $value) { |
|
| 6528 | $carry[] = $value; |
|
| 6529 | ||
| 6530 | if ($i % $numberOfPieces !== 0) { |
|
| 6531 | ++$i; |
|
| 6532 | ||
| 6533 | continue; |
|
| 6534 | } |
|
| 6535 | ||
| 6536 | yield $carry; |
|
| 6537 | ||
| 6538 | $carry = []; |
|
| 6539 | $i = 1; |
|
| 6540 | } |
|
| 6541 | ||
| 6542 | if ($carry !== []) { |
|
| 6543 | yield $carry; |
|
| 6544 | } |
|
| 6545 | }; |
|
| 6546 | } |
|
| 6547 | ||
| 6548 | return static::create( |
|
| 6549 | $generator, |
|