| @@ 4641-4656 (lines=16) @@ | ||
| 4638 | * @phpstan-return static<TKey,T> |
|
| 4639 | * @psalm-mutation-free |
|
| 4640 | */ |
|
| 4641 | public function moveElementToFirstPlace($key): self |
|
| 4642 | { |
|
| 4643 | $array = $this->toArray(); |
|
| 4644 | ||
| 4645 | if ($this->offsetExists($key)) { |
|
| 4646 | $tmpValue = $this->get($key); |
|
| 4647 | unset($array[$key]); |
|
| 4648 | $array = [$key => $tmpValue] + $array; |
|
| 4649 | } |
|
| 4650 | ||
| 4651 | return static::create( |
|
| 4652 | $array, |
|
| 4653 | $this->iteratorClass, |
|
| 4654 | false |
|
| 4655 | ); |
|
| 4656 | } |
|
| 4657 | ||
| 4658 | /** |
|
| 4659 | * Move an array element to the last place. |
|
| @@ 4672-4687 (lines=16) @@ | ||
| 4669 | * @phpstan-return static<TKey,T> |
|
| 4670 | * @psalm-mutation-free |
|
| 4671 | */ |
|
| 4672 | public function moveElementToLastPlace($key): self |
|
| 4673 | { |
|
| 4674 | $array = $this->toArray(); |
|
| 4675 | ||
| 4676 | if ($this->offsetExists($key)) { |
|
| 4677 | $tmpValue = $this->get($key); |
|
| 4678 | unset($array[$key]); |
|
| 4679 | $array += [$key => $tmpValue]; |
|
| 4680 | } |
|
| 4681 | ||
| 4682 | return static::create( |
|
| 4683 | $array, |
|
| 4684 | $this->iteratorClass, |
|
| 4685 | false |
|
| 4686 | ); |
|
| 4687 | } |
|
| 4688 | ||
| 4689 | /** |
|
| 4690 | * Moves the internal iterator position to the next element and returns this element. |
|