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