| @@ 4093-4108 (lines=16) @@ | ||
| 4090 | * @psalm-return static<TKey,T> |
|
| 4091 | * @psalm-mutation-free |
|
| 4092 | */ |
|
| 4093 | public function moveElementToFirstPlace($key): self |
|
| 4094 | { |
|
| 4095 | $array = $this->toArray(); |
|
| 4096 | ||
| 4097 | if ($this->offsetExists($key)) { |
|
| 4098 | $tmpValue = $this->get($key); |
|
| 4099 | unset($array[$key]); |
|
| 4100 | $array = [$key => $tmpValue] + $array; |
|
| 4101 | } |
|
| 4102 | ||
| 4103 | return static::create( |
|
| 4104 | $array, |
|
| 4105 | $this->iteratorClass, |
|
| 4106 | false |
|
| 4107 | ); |
|
| 4108 | } |
|
| 4109 | ||
| 4110 | /** |
|
| 4111 | * Move an array element to the last place. |
|
| @@ 4124-4139 (lines=16) @@ | ||
| 4121 | * @psalm-return static<TKey,T> |
|
| 4122 | * @psalm-mutation-free |
|
| 4123 | */ |
|
| 4124 | public function moveElementToLastPlace($key): self |
|
| 4125 | { |
|
| 4126 | $array = $this->toArray(); |
|
| 4127 | ||
| 4128 | if ($this->offsetExists($key)) { |
|
| 4129 | $tmpValue = $this->get($key); |
|
| 4130 | unset($array[$key]); |
|
| 4131 | $array += [$key => $tmpValue]; |
|
| 4132 | } |
|
| 4133 | ||
| 4134 | return static::create( |
|
| 4135 | $array, |
|
| 4136 | $this->iteratorClass, |
|
| 4137 | false |
|
| 4138 | ); |
|
| 4139 | } |
|
| 4140 | ||
| 4141 | /** |
|
| 4142 | * Moves the internal iterator position to the next element and returns this element. |
|