| @@ 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, |
|
| @@ 6583-6606 (lines=24) @@ | ||
| 6580 | yield $carry; |
|
| 6581 | } |
|
| 6582 | }; |
|
| 6583 | } else { |
|
| 6584 | $generator = function () use ($numberOfPieces) { |
|
| 6585 | $carry = []; |
|
| 6586 | $i = 1; |
|
| 6587 | foreach ($this->getGenerator() as $key => $value) { |
|
| 6588 | $carry[] = $value; |
|
| 6589 | ||
| 6590 | if ($i % $numberOfPieces !== 0) { |
|
| 6591 | ++$i; |
|
| 6592 | ||
| 6593 | continue; |
|
| 6594 | } |
|
| 6595 | ||
| 6596 | yield $carry; |
|
| 6597 | ||
| 6598 | $carry = []; |
|
| 6599 | $i = 1; |
|
| 6600 | } |
|
| 6601 | ||
| 6602 | if ($carry !== []) { |
|
| 6603 | yield $carry; |
|
| 6604 | } |
|
| 6605 | }; |
|
| 6606 | } |
|
| 6607 | ||
| 6608 | return static::create( |
|
| 6609 | $generator, |
|