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