| @@ 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, |
|
| @@ 6521-6544 (lines=24) @@ | ||
| 6518 | yield $carry; |
|
| 6519 | } |
|
| 6520 | }; |
|
| 6521 | } else { |
|
| 6522 | $generator = function () use ($numberOfPieces) { |
|
| 6523 | $carry = []; |
|
| 6524 | $i = 1; |
|
| 6525 | foreach ($this->getGenerator() as $key => $value) { |
|
| 6526 | $carry[] = $value; |
|
| 6527 | ||
| 6528 | if ($i % $numberOfPieces !== 0) { |
|
| 6529 | ++$i; |
|
| 6530 | ||
| 6531 | continue; |
|
| 6532 | } |
|
| 6533 | ||
| 6534 | yield $carry; |
|
| 6535 | ||
| 6536 | $carry = []; |
|
| 6537 | $i = 1; |
|
| 6538 | } |
|
| 6539 | ||
| 6540 | if ($carry !== []) { |
|
| 6541 | yield $carry; |
|
| 6542 | } |
|
| 6543 | }; |
|
| 6544 | } |
|
| 6545 | ||
| 6546 | return static::create( |
|
| 6547 | $generator, |
|