| @@ 4080-4095 (lines=16) @@ | ||
| 4077 | * @psalm-return static<TKey,T> |
|
| 4078 | * @psalm-mutation-free |
|
| 4079 | */ |
|
| 4080 | public function moveElementToFirstPlace($key): self |
|
| 4081 | { |
|
| 4082 | $array = $this->toArray(); |
|
| 4083 | ||
| 4084 | if ($this->offsetExists($key)) { |
|
| 4085 | $tmpValue = $this->get($key); |
|
| 4086 | unset($array[$key]); |
|
| 4087 | $array = [$key => $tmpValue] + $array; |
|
| 4088 | } |
|
| 4089 | ||
| 4090 | return static::create( |
|
| 4091 | $array, |
|
| 4092 | $this->iteratorClass, |
|
| 4093 | false |
|
| 4094 | ); |
|
| 4095 | } |
|
| 4096 | ||
| 4097 | /** |
|
| 4098 | * Move an array element to the last place. |
|
| @@ 4111-4126 (lines=16) @@ | ||
| 4108 | * @psalm-return static<TKey,T> |
|
| 4109 | * @psalm-mutation-free |
|
| 4110 | */ |
|
| 4111 | public function moveElementToLastPlace($key): self |
|
| 4112 | { |
|
| 4113 | $array = $this->toArray(); |
|
| 4114 | ||
| 4115 | if ($this->offsetExists($key)) { |
|
| 4116 | $tmpValue = $this->get($key); |
|
| 4117 | unset($array[$key]); |
|
| 4118 | $array += [$key => $tmpValue]; |
|
| 4119 | } |
|
| 4120 | ||
| 4121 | return static::create( |
|
| 4122 | $array, |
|
| 4123 | $this->iteratorClass, |
|
| 4124 | false |
|
| 4125 | ); |
|
| 4126 | } |
|
| 4127 | ||
| 4128 | /** |
|
| 4129 | * Moves the internal iterator position to the next element and returns this element. |
|