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