| @@ 3929-3944 (lines=16) @@ | ||
| 3926 | * @psalm-return static<TKey,T> |
|
| 3927 | * @psalm-mutation-free |
|
| 3928 | */ |
|
| 3929 | public function moveElementToFirstPlace($key): self |
|
| 3930 | { |
|
| 3931 | $array = $this->toArray(); |
|
| 3932 | ||
| 3933 | if ($this->offsetExists($key)) { |
|
| 3934 | $tmpValue = $this->get($key); |
|
| 3935 | unset($array[$key]); |
|
| 3936 | $array = [$key => $tmpValue] + $array; |
|
| 3937 | } |
|
| 3938 | ||
| 3939 | return static::create( |
|
| 3940 | $array, |
|
| 3941 | $this->iteratorClass, |
|
| 3942 | false |
|
| 3943 | ); |
|
| 3944 | } |
|
| 3945 | ||
| 3946 | /** |
|
| 3947 | * Move an array element to the last place. |
|
| @@ 3960-3975 (lines=16) @@ | ||
| 3957 | * @psalm-return static<TKey,T> |
|
| 3958 | * @psalm-mutation-free |
|
| 3959 | */ |
|
| 3960 | public function moveElementToLastPlace($key): self |
|
| 3961 | { |
|
| 3962 | $array = $this->toArray(); |
|
| 3963 | ||
| 3964 | if ($this->offsetExists($key)) { |
|
| 3965 | $tmpValue = $this->get($key); |
|
| 3966 | unset($array[$key]); |
|
| 3967 | $array += [$key => $tmpValue]; |
|
| 3968 | } |
|
| 3969 | ||
| 3970 | return static::create( |
|
| 3971 | $array, |
|
| 3972 | $this->iteratorClass, |
|
| 3973 | false |
|
| 3974 | ); |
|
| 3975 | } |
|
| 3976 | ||
| 3977 | /** |
|
| 3978 | * Moves the internal iterator position to the next element and returns this element. |
|