| @@ 1571-1583 (lines=13) @@ | ||
| 1568 | * @return static |
|
| 1569 | * <p>(Immutable)</p> |
|
| 1570 | */ |
|
| 1571 | public function firstsImmutable(int $number = null): self |
|
| 1572 | { |
|
| 1573 | if ($number === null) { |
|
| 1574 | $arrayTmp = $this->array; |
|
| 1575 | $array = (array) \array_shift($arrayTmp); |
|
| 1576 | } else { |
|
| 1577 | $number = (int) $number; |
|
| 1578 | $arrayTmp = $this->array; |
|
| 1579 | $array = \array_splice($arrayTmp, 0, $number); |
|
| 1580 | } |
|
| 1581 | ||
| 1582 | return static::create($array, $this->iteratorClass, false); |
|
| 1583 | } |
|
| 1584 | ||
| 1585 | /** |
|
| 1586 | * Get the first value(s) from the current array. |
|
| @@ 3446-3458 (lines=13) @@ | ||
| 3443 | * @return static |
|
| 3444 | * <p>(Immutable)</p> |
|
| 3445 | */ |
|
| 3446 | public function split(int $numberOfPieces = 2, bool $keepKeys = false): self |
|
| 3447 | { |
|
| 3448 | $arrayCount = \count($this->array, \COUNT_NORMAL); |
|
| 3449 | ||
| 3450 | if ($arrayCount === 0) { |
|
| 3451 | $result = []; |
|
| 3452 | } else { |
|
| 3453 | $splitSize = (int) \ceil($arrayCount / $numberOfPieces); |
|
| 3454 | $result = \array_chunk($this->array, $splitSize, $keepKeys); |
|
| 3455 | } |
|
| 3456 | ||
| 3457 | return static::create($result, $this->iteratorClass, false); |
|
| 3458 | } |
|
| 3459 | ||
| 3460 | /** |
|
| 3461 | * Stripe all empty items. |
|