| @@ 1284-1304 (lines=21) @@ | ||
| 1281 | yield $values; |
|
| 1282 | } |
|
| 1283 | }; |
|
| 1284 | } else { |
|
| 1285 | $generator = function () use ($size) { |
|
| 1286 | $values = []; |
|
| 1287 | $tmpCounter = 0; |
|
| 1288 | foreach ($this->getGenerator() as $key => $value) { |
|
| 1289 | ++$tmpCounter; |
|
| 1290 | ||
| 1291 | $values[] = $value; |
|
| 1292 | if ($tmpCounter === $size) { |
|
| 1293 | yield $values; |
|
| 1294 | ||
| 1295 | $values = []; |
|
| 1296 | $tmpCounter = 0; |
|
| 1297 | } |
|
| 1298 | } |
|
| 1299 | ||
| 1300 | if ($values !== []) { |
|
| 1301 | yield $values; |
|
| 1302 | } |
|
| 1303 | }; |
|
| 1304 | } |
|
| 1305 | ||
| 1306 | return static::create( |
|
| 1307 | $generator, |
|
| @@ 6410-6433 (lines=24) @@ | ||
| 6407 | yield $carry; |
|
| 6408 | } |
|
| 6409 | }; |
|
| 6410 | } else { |
|
| 6411 | $generator = function () use ($numberOfPieces) { |
|
| 6412 | $carry = []; |
|
| 6413 | $i = 1; |
|
| 6414 | foreach ($this->getGenerator() as $key => $value) { |
|
| 6415 | $carry[] = $value; |
|
| 6416 | ||
| 6417 | if ($i % $numberOfPieces !== 0) { |
|
| 6418 | ++$i; |
|
| 6419 | ||
| 6420 | continue; |
|
| 6421 | } |
|
| 6422 | ||
| 6423 | yield $carry; |
|
| 6424 | ||
| 6425 | $carry = []; |
|
| 6426 | $i = 1; |
|
| 6427 | } |
|
| 6428 | ||
| 6429 | if ($carry !== []) { |
|
| 6430 | yield $carry; |
|
| 6431 | } |
|
| 6432 | }; |
|
| 6433 | } |
|
| 6434 | ||
| 6435 | return static::create( |
|
| 6436 | $generator, |
|