| @@ 1277-1297 (lines=21) @@ | ||
| 1274 | yield $values; |
|
| 1275 | } |
|
| 1276 | }; |
|
| 1277 | } else { |
|
| 1278 | $generator = function () use ($size) { |
|
| 1279 | $values = []; |
|
| 1280 | $tmpCounter = 0; |
|
| 1281 | foreach ($this->getGenerator() as $key => $value) { |
|
| 1282 | ++$tmpCounter; |
|
| 1283 | ||
| 1284 | $values[] = $value; |
|
| 1285 | if ($tmpCounter === $size) { |
|
| 1286 | yield $values; |
|
| 1287 | ||
| 1288 | $values = []; |
|
| 1289 | $tmpCounter = 0; |
|
| 1290 | } |
|
| 1291 | } |
|
| 1292 | ||
| 1293 | if ($values !== []) { |
|
| 1294 | yield $values; |
|
| 1295 | } |
|
| 1296 | }; |
|
| 1297 | } |
|
| 1298 | ||
| 1299 | return static::create( |
|
| 1300 | $generator, |
|
| @@ 6422-6445 (lines=24) @@ | ||
| 6419 | yield $carry; |
|
| 6420 | } |
|
| 6421 | }; |
|
| 6422 | } else { |
|
| 6423 | $generator = function () use ($numberOfPieces) { |
|
| 6424 | $carry = []; |
|
| 6425 | $i = 1; |
|
| 6426 | foreach ($this->getGenerator() as $key => $value) { |
|
| 6427 | $carry[] = $value; |
|
| 6428 | ||
| 6429 | if ($i % $numberOfPieces !== 0) { |
|
| 6430 | ++$i; |
|
| 6431 | ||
| 6432 | continue; |
|
| 6433 | } |
|
| 6434 | ||
| 6435 | yield $carry; |
|
| 6436 | ||
| 6437 | $carry = []; |
|
| 6438 | $i = 1; |
|
| 6439 | } |
|
| 6440 | ||
| 6441 | if ($carry !== []) { |
|
| 6442 | yield $carry; |
|
| 6443 | } |
|
| 6444 | }; |
|
| 6445 | } |
|
| 6446 | ||
| 6447 | return static::create( |
|
| 6448 | $generator, |
|