| @@ 2620-2635 (lines=16) @@ | ||
| 2617 | * @psalm-return static<TKey,T> |
|
| 2618 | * @psalm-mutation-free |
|
| 2619 | */ |
|
| 2620 | public function firstsImmutable(int $number = null): self |
|
| 2621 | { |
|
| 2622 | $arrayTmp = $this->toArray(); |
|
| 2623 | ||
| 2624 | if ($number === null) { |
|
| 2625 | $array = (array) \array_shift($arrayTmp); |
|
| 2626 | } else { |
|
| 2627 | $array = \array_splice($arrayTmp, 0, $number); |
|
| 2628 | } |
|
| 2629 | ||
| 2630 | return static::create( |
|
| 2631 | $array, |
|
| 2632 | $this->iteratorClass, |
|
| 2633 | false |
|
| 2634 | ); |
|
| 2635 | } |
|
| 2636 | ||
| 2637 | /** |
|
| 2638 | * Get the first value(s) from the current array. |
|
| @@ 2649-2664 (lines=16) @@ | ||
| 2646 | * @psalm-return static<TKey,T> |
|
| 2647 | * @psalm-mutation-free |
|
| 2648 | */ |
|
| 2649 | public function firstsKeys(int $number = null): self |
|
| 2650 | { |
|
| 2651 | $arrayTmp = $this->keys()->toArray(); |
|
| 2652 | ||
| 2653 | if ($number === null) { |
|
| 2654 | $array = (array) \array_shift($arrayTmp); |
|
| 2655 | } else { |
|
| 2656 | $array = \array_splice($arrayTmp, 0, $number); |
|
| 2657 | } |
|
| 2658 | ||
| 2659 | return static::create( |
|
| 2660 | $array, |
|
| 2661 | $this->iteratorClass, |
|
| 2662 | false |
|
| 2663 | ); |
|
| 2664 | } |
|
| 2665 | ||
| 2666 | /** |
|
| 2667 | * Get and remove the first value(s) from the current array. |
|
| @@ 5573-5587 (lines=15) @@ | ||
| 5570 | * @psalm-return static<TKey,T> |
|
| 5571 | * @psalm-mutation-free |
|
| 5572 | */ |
|
| 5573 | public function replaceOneValue($search, $replacement = ''): self |
|
| 5574 | { |
|
| 5575 | $array = $this->toArray(); |
|
| 5576 | $key = \array_search($search, $array, true); |
|
| 5577 | ||
| 5578 | if ($key !== false) { |
|
| 5579 | $array[$key] = $replacement; |
|
| 5580 | } |
|
| 5581 | ||
| 5582 | return static::create( |
|
| 5583 | $array, |
|
| 5584 | $this->iteratorClass, |
|
| 5585 | false |
|
| 5586 | ); |
|
| 5587 | } |
|
| 5588 | ||
| 5589 | /** |
|
| 5590 | * Replace values in the current array. |
|