| @@ 3759-3774 (lines=16) @@ | ||
| 3756 | * @psalm-return static<TKey,T> |
|
| 3757 | * @psalm-mutation-free |
|
| 3758 | */ |
|
| 3759 | public function moveElementToFirstPlace($key): self |
|
| 3760 | { |
|
| 3761 | $array = $this->toArray(); |
|
| 3762 | ||
| 3763 | if ($this->offsetExists($key)) { |
|
| 3764 | $tmpValue = $this->get($key); |
|
| 3765 | unset($array[$key]); |
|
| 3766 | $array = [$key => $tmpValue] + $array; |
|
| 3767 | } |
|
| 3768 | ||
| 3769 | return static::create( |
|
| 3770 | $array, |
|
| 3771 | $this->iteratorClass, |
|
| 3772 | false |
|
| 3773 | ); |
|
| 3774 | } |
|
| 3775 | ||
| 3776 | /** |
|
| 3777 | * Move an array element to the last place. |
|
| @@ 3790-3805 (lines=16) @@ | ||
| 3787 | * @psalm-return static<TKey,T> |
|
| 3788 | * @psalm-mutation-free |
|
| 3789 | */ |
|
| 3790 | public function moveElementToLastPlace($key): self |
|
| 3791 | { |
|
| 3792 | $array = $this->toArray(); |
|
| 3793 | ||
| 3794 | if ($this->offsetExists($key)) { |
|
| 3795 | $tmpValue = $this->get($key); |
|
| 3796 | unset($array[$key]); |
|
| 3797 | $array += [$key => $tmpValue]; |
|
| 3798 | } |
|
| 3799 | ||
| 3800 | return static::create( |
|
| 3801 | $array, |
|
| 3802 | $this->iteratorClass, |
|
| 3803 | false |
|
| 3804 | ); |
|
| 3805 | } |
|
| 3806 | ||
| 3807 | /** |
|
| 3808 | * Moves the internal iterator position to the next element and returns this element. |
|