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