| @@ 4498-4513 (lines=16) @@ | ||
| 4495 | * @psalm-return static<TKey,T> |
|
| 4496 | * @psalm-mutation-free |
|
| 4497 | */ |
|
| 4498 | public function moveElementToFirstPlace($key): self |
|
| 4499 | { |
|
| 4500 | $array = $this->toArray(); |
|
| 4501 | ||
| 4502 | if ($this->offsetExists($key)) { |
|
| 4503 | $tmpValue = $this->get($key); |
|
| 4504 | unset($array[$key]); |
|
| 4505 | $array = [$key => $tmpValue] + $array; |
|
| 4506 | } |
|
| 4507 | ||
| 4508 | return static::create( |
|
| 4509 | $array, |
|
| 4510 | $this->iteratorClass, |
|
| 4511 | false |
|
| 4512 | ); |
|
| 4513 | } |
|
| 4514 | ||
| 4515 | /** |
|
| 4516 | * Move an array element to the last place. |
|
| @@ 4529-4544 (lines=16) @@ | ||
| 4526 | * @psalm-return static<TKey,T> |
|
| 4527 | * @psalm-mutation-free |
|
| 4528 | */ |
|
| 4529 | public function moveElementToLastPlace($key): self |
|
| 4530 | { |
|
| 4531 | $array = $this->toArray(); |
|
| 4532 | ||
| 4533 | if ($this->offsetExists($key)) { |
|
| 4534 | $tmpValue = $this->get($key); |
|
| 4535 | unset($array[$key]); |
|
| 4536 | $array += [$key => $tmpValue]; |
|
| 4537 | } |
|
| 4538 | ||
| 4539 | return static::create( |
|
| 4540 | $array, |
|
| 4541 | $this->iteratorClass, |
|
| 4542 | false |
|
| 4543 | ); |
|
| 4544 | } |
|
| 4545 | ||
| 4546 | /** |
|
| 4547 | * Moves the internal iterator position to the next element and returns this element. |
|