@@ 2567-2582 (lines=16) @@ | ||
2564 | * @psalm-return static<TKey,T> |
|
2565 | * @psalm-mutation-free |
|
2566 | */ |
|
2567 | public function firstsImmutable(int $number = null): self |
|
2568 | { |
|
2569 | $arrayTmp = $this->toArray(); |
|
2570 | ||
2571 | if ($number === null) { |
|
2572 | $array = (array) \array_shift($arrayTmp); |
|
2573 | } else { |
|
2574 | $array = \array_splice($arrayTmp, 0, $number); |
|
2575 | } |
|
2576 | ||
2577 | return static::create( |
|
2578 | $array, |
|
2579 | $this->iteratorClass, |
|
2580 | false |
|
2581 | ); |
|
2582 | } |
|
2583 | ||
2584 | /** |
|
2585 | * Get the first value(s) from the current array. |
|
@@ 2596-2611 (lines=16) @@ | ||
2593 | * @psalm-return static<TKey,T> |
|
2594 | * @psalm-mutation-free |
|
2595 | */ |
|
2596 | public function firstsKeys(int $number = null): self |
|
2597 | { |
|
2598 | $arrayTmp = $this->keys()->toArray(); |
|
2599 | ||
2600 | if ($number === null) { |
|
2601 | $array = (array) \array_shift($arrayTmp); |
|
2602 | } else { |
|
2603 | $array = \array_splice($arrayTmp, 0, $number); |
|
2604 | } |
|
2605 | ||
2606 | return static::create( |
|
2607 | $array, |
|
2608 | $this->iteratorClass, |
|
2609 | false |
|
2610 | ); |
|
2611 | } |
|
2612 | ||
2613 | /** |
|
2614 | * Get and remove the first value(s) from the current array. |
|
@@ 5486-5500 (lines=15) @@ | ||
5483 | * @psalm-return static<TKey,T> |
|
5484 | * @psalm-mutation-free |
|
5485 | */ |
|
5486 | public function replaceOneValue($search, $replacement = ''): self |
|
5487 | { |
|
5488 | $array = $this->toArray(); |
|
5489 | $key = \array_search($search, $array, true); |
|
5490 | ||
5491 | if ($key !== false) { |
|
5492 | $array[$key] = $replacement; |
|
5493 | } |
|
5494 | ||
5495 | return static::create( |
|
5496 | $array, |
|
5497 | $this->iteratorClass, |
|
5498 | false |
|
5499 | ); |
|
5500 | } |
|
5501 | ||
5502 | /** |
|
5503 | * Replace values in the current array. |