| @@ 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. |
|
| @@ 5470-5484 (lines=15) @@ | ||
| 5467 | * @psalm-return static<TKey,T> |
|
| 5468 | * @psalm-mutation-free |
|
| 5469 | */ |
|
| 5470 | public function replaceOneValue($search, $replacement = ''): self |
|
| 5471 | { |
|
| 5472 | $array = $this->toArray(); |
|
| 5473 | $key = \array_search($search, $array, true); |
|
| 5474 | ||
| 5475 | if ($key !== false) { |
|
| 5476 | $array[$key] = $replacement; |
|
| 5477 | } |
|
| 5478 | ||
| 5479 | return static::create( |
|
| 5480 | $array, |
|
| 5481 | $this->iteratorClass, |
|
| 5482 | false |
|
| 5483 | ); |
|
| 5484 | } |
|
| 5485 | ||
| 5486 | /** |
|
| 5487 | * Replace values in the current array. |
|