@@ 4393-4408 (lines=16) @@ | ||
4390 | * @psalm-return static<TKey,T> |
|
4391 | * @psalm-mutation-free |
|
4392 | */ |
|
4393 | public function moveElementToFirstPlace($key): self |
|
4394 | { |
|
4395 | $array = $this->toArray(); |
|
4396 | ||
4397 | if ($this->offsetExists($key)) { |
|
4398 | $tmpValue = $this->get($key); |
|
4399 | unset($array[$key]); |
|
4400 | $array = [$key => $tmpValue] + $array; |
|
4401 | } |
|
4402 | ||
4403 | return static::create( |
|
4404 | $array, |
|
4405 | $this->iteratorClass, |
|
4406 | false |
|
4407 | ); |
|
4408 | } |
|
4409 | ||
4410 | /** |
|
4411 | * Move an array element to the last place. |
|
@@ 4424-4439 (lines=16) @@ | ||
4421 | * @psalm-return static<TKey,T> |
|
4422 | * @psalm-mutation-free |
|
4423 | */ |
|
4424 | public function moveElementToLastPlace($key): self |
|
4425 | { |
|
4426 | $array = $this->toArray(); |
|
4427 | ||
4428 | if ($this->offsetExists($key)) { |
|
4429 | $tmpValue = $this->get($key); |
|
4430 | unset($array[$key]); |
|
4431 | $array += [$key => $tmpValue]; |
|
4432 | } |
|
4433 | ||
4434 | return static::create( |
|
4435 | $array, |
|
4436 | $this->iteratorClass, |
|
4437 | false |
|
4438 | ); |
|
4439 | } |
|
4440 | ||
4441 | /** |
|
4442 | * Moves the internal iterator position to the next element and returns this element. |