| @@ 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, |
|
| @@ 6394-6417 (lines=24) @@ | ||
| 6391 | yield $carry; |
|
| 6392 | } |
|
| 6393 | }; |
|
| 6394 | } else { |
|
| 6395 | $generator = function () use ($numberOfPieces) { |
|
| 6396 | $carry = []; |
|
| 6397 | $i = 1; |
|
| 6398 | foreach ($this->getGenerator() as $key => $value) { |
|
| 6399 | $carry[] = $value; |
|
| 6400 | ||
| 6401 | if ($i % $numberOfPieces !== 0) { |
|
| 6402 | ++$i; |
|
| 6403 | ||
| 6404 | continue; |
|
| 6405 | } |
|
| 6406 | ||
| 6407 | yield $carry; |
|
| 6408 | ||
| 6409 | $carry = []; |
|
| 6410 | $i = 1; |
|
| 6411 | } |
|
| 6412 | ||
| 6413 | if ($carry !== []) { |
|
| 6414 | yield $carry; |
|
| 6415 | } |
|
| 6416 | }; |
|
| 6417 | } |
|
| 6418 | ||
| 6419 | return static::create( |
|
| 6420 | $generator, |
|