| @@ 6283-6304 (lines=22) @@ | ||
| 6280 | public function split(int $numberOfPieces = 2, bool $keepKeys = false): self |
|
| 6281 | { |
|
| 6282 | if ($keepKeys) { |
|
| 6283 | $generator = function () use ($numberOfPieces) { |
|
| 6284 | $carry = []; |
|
| 6285 | $i = 1; |
|
| 6286 | foreach ($this->getGenerator() as $key => $value) { |
|
| 6287 | $carry[$key] = $value; |
|
| 6288 | ||
| 6289 | if ($i % $numberOfPieces !== 0) { |
|
| 6290 | ++$i; |
|
| 6291 | ||
| 6292 | continue; |
|
| 6293 | } |
|
| 6294 | ||
| 6295 | yield $carry; |
|
| 6296 | ||
| 6297 | $carry = []; |
|
| 6298 | $i = 1; |
|
| 6299 | } |
|
| 6300 | ||
| 6301 | if ($carry !== []) { |
|
| 6302 | yield $carry; |
|
| 6303 | } |
|
| 6304 | }; |
|
| 6305 | } else { |
|
| 6306 | $generator = function () use ($numberOfPieces) { |
|
| 6307 | $carry = []; |
|
| @@ 6306-6327 (lines=22) @@ | ||
| 6303 | } |
|
| 6304 | }; |
|
| 6305 | } else { |
|
| 6306 | $generator = function () use ($numberOfPieces) { |
|
| 6307 | $carry = []; |
|
| 6308 | $i = 1; |
|
| 6309 | foreach ($this->getGenerator() as $key => $value) { |
|
| 6310 | $carry[] = $value; |
|
| 6311 | ||
| 6312 | if ($i % $numberOfPieces !== 0) { |
|
| 6313 | ++$i; |
|
| 6314 | ||
| 6315 | continue; |
|
| 6316 | } |
|
| 6317 | ||
| 6318 | yield $carry; |
|
| 6319 | ||
| 6320 | $carry = []; |
|
| 6321 | $i = 1; |
|
| 6322 | } |
|
| 6323 | ||
| 6324 | if ($carry !== []) { |
|
| 6325 | yield $carry; |
|
| 6326 | } |
|
| 6327 | }; |
|
| 6328 | } |
|
| 6329 | ||
| 6330 | return static::create( |
|