| @@ 3863-3878 (lines=16) @@ | ||
| 3860 | * @psalm-return static<TKey,T> |
|
| 3861 | * @psalm-mutation-free |
|
| 3862 | */ |
|
| 3863 | public function moveElementToFirstPlace($key): self |
|
| 3864 | { |
|
| 3865 | $array = $this->toArray(); |
|
| 3866 | ||
| 3867 | if ($this->offsetExists($key)) { |
|
| 3868 | $tmpValue = $this->get($key); |
|
| 3869 | unset($array[$key]); |
|
| 3870 | $array = [$key => $tmpValue] + $array; |
|
| 3871 | } |
|
| 3872 | ||
| 3873 | return static::create( |
|
| 3874 | $array, |
|
| 3875 | $this->iteratorClass, |
|
| 3876 | false |
|
| 3877 | ); |
|
| 3878 | } |
|
| 3879 | ||
| 3880 | /** |
|
| 3881 | * Move an array element to the last place. |
|
| @@ 3894-3909 (lines=16) @@ | ||
| 3891 | * @psalm-return static<TKey,T> |
|
| 3892 | * @psalm-mutation-free |
|
| 3893 | */ |
|
| 3894 | public function moveElementToLastPlace($key): self |
|
| 3895 | { |
|
| 3896 | $array = $this->toArray(); |
|
| 3897 | ||
| 3898 | if ($this->offsetExists($key)) { |
|
| 3899 | $tmpValue = $this->get($key); |
|
| 3900 | unset($array[$key]); |
|
| 3901 | $array += [$key => $tmpValue]; |
|
| 3902 | } |
|
| 3903 | ||
| 3904 | return static::create( |
|
| 3905 | $array, |
|
| 3906 | $this->iteratorClass, |
|
| 3907 | false |
|
| 3908 | ); |
|
| 3909 | } |
|
| 3910 | ||
| 3911 | /** |
|
| 3912 | * Moves the internal iterator position to the next element and returns this element. |
|