| @@ 1320-1340 (lines=21) @@ | ||
| 1317 | yield $values; |
|
| 1318 | } |
|
| 1319 | }; |
|
| 1320 | } else { |
|
| 1321 | $generator = function () use ($size) { |
|
| 1322 | $values = []; |
|
| 1323 | $tmpCounter = 0; |
|
| 1324 | foreach ($this->getGenerator() as $value) { |
|
| 1325 | ++$tmpCounter; |
|
| 1326 | ||
| 1327 | $values[] = $value; |
|
| 1328 | if ($tmpCounter === $size) { |
|
| 1329 | yield $values; |
|
| 1330 | ||
| 1331 | $values = []; |
|
| 1332 | $tmpCounter = 0; |
|
| 1333 | } |
|
| 1334 | } |
|
| 1335 | ||
| 1336 | if ($values !== []) { |
|
| 1337 | yield $values; |
|
| 1338 | } |
|
| 1339 | }; |
|
| 1340 | } |
|
| 1341 | ||
| 1342 | return static::create( |
|
| 1343 | $generator, |
|
| @@ 6620-6643 (lines=24) @@ | ||
| 6617 | yield $carry; |
|
| 6618 | } |
|
| 6619 | }; |
|
| 6620 | } else { |
|
| 6621 | $generator = function () use ($numberOfPieces) { |
|
| 6622 | $carry = []; |
|
| 6623 | $i = 1; |
|
| 6624 | foreach ($this->getGenerator() as $value) { |
|
| 6625 | $carry[] = $value; |
|
| 6626 | ||
| 6627 | if ($i % $numberOfPieces !== 0) { |
|
| 6628 | ++$i; |
|
| 6629 | ||
| 6630 | continue; |
|
| 6631 | } |
|
| 6632 | ||
| 6633 | yield $carry; |
|
| 6634 | ||
| 6635 | $carry = []; |
|
| 6636 | $i = 1; |
|
| 6637 | } |
|
| 6638 | ||
| 6639 | if ($carry !== []) { |
|
| 6640 | yield $carry; |
|
| 6641 | } |
|
| 6642 | }; |
|
| 6643 | } |
|
| 6644 | ||
| 6645 | return static::create( |
|
| 6646 | $generator, |
|