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