| @@ 6267-6288 (lines=22) @@ | ||
| 6264 | public function split(int $numberOfPieces = 2, bool $keepKeys = false): self |
|
| 6265 | { |
|
| 6266 | if ($keepKeys) { |
|
| 6267 | $generator = function () use ($numberOfPieces) { |
|
| 6268 | $carry = []; |
|
| 6269 | $i = 1; |
|
| 6270 | foreach ($this->getGenerator() as $key => $value) { |
|
| 6271 | $carry[$key] = $value; |
|
| 6272 | ||
| 6273 | if ($i % $numberOfPieces !== 0) { |
|
| 6274 | ++$i; |
|
| 6275 | ||
| 6276 | continue; |
|
| 6277 | } |
|
| 6278 | ||
| 6279 | yield $carry; |
|
| 6280 | ||
| 6281 | $carry = []; |
|
| 6282 | $i = 1; |
|
| 6283 | } |
|
| 6284 | ||
| 6285 | if ($carry !== []) { |
|
| 6286 | yield $carry; |
|
| 6287 | } |
|
| 6288 | }; |
|
| 6289 | } else { |
|
| 6290 | $generator = function () use ($numberOfPieces) { |
|
| 6291 | $carry = []; |
|
| @@ 6290-6311 (lines=22) @@ | ||
| 6287 | } |
|
| 6288 | }; |
|
| 6289 | } else { |
|
| 6290 | $generator = function () use ($numberOfPieces) { |
|
| 6291 | $carry = []; |
|
| 6292 | $i = 1; |
|
| 6293 | foreach ($this->getGenerator() as $key => $value) { |
|
| 6294 | $carry[] = $value; |
|
| 6295 | ||
| 6296 | if ($i % $numberOfPieces !== 0) { |
|
| 6297 | ++$i; |
|
| 6298 | ||
| 6299 | continue; |
|
| 6300 | } |
|
| 6301 | ||
| 6302 | yield $carry; |
|
| 6303 | ||
| 6304 | $carry = []; |
|
| 6305 | $i = 1; |
|
| 6306 | } |
|
| 6307 | ||
| 6308 | if ($carry !== []) { |
|
| 6309 | yield $carry; |
|
| 6310 | } |
|
| 6311 | }; |
|
| 6312 | } |
|
| 6313 | ||
| 6314 | return static::create( |
|