| @@ 4681-4696 (lines=16) @@ | ||
| 4678 | * @phpstan-return static<TKey,T> |
|
| 4679 | * @psalm-mutation-free |
|
| 4680 | */ |
|
| 4681 | public function moveElementToFirstPlace($key): self |
|
| 4682 | { |
|
| 4683 | $array = $this->toArray(); |
|
| 4684 | ||
| 4685 | if ($this->offsetExists($key)) { |
|
| 4686 | $tmpValue = $this->get($key); |
|
| 4687 | unset($array[$key]); |
|
| 4688 | $array = [$key => $tmpValue] + $array; |
|
| 4689 | } |
|
| 4690 | ||
| 4691 | return static::create( |
|
| 4692 | $array, |
|
| 4693 | $this->iteratorClass, |
|
| 4694 | false |
|
| 4695 | ); |
|
| 4696 | } |
|
| 4697 | ||
| 4698 | /** |
|
| 4699 | * Move an array element to the last place. |
|
| @@ 4712-4727 (lines=16) @@ | ||
| 4709 | * @phpstan-return static<TKey,T> |
|
| 4710 | * @psalm-mutation-free |
|
| 4711 | */ |
|
| 4712 | public function moveElementToLastPlace($key): self |
|
| 4713 | { |
|
| 4714 | $array = $this->toArray(); |
|
| 4715 | ||
| 4716 | if ($this->offsetExists($key)) { |
|
| 4717 | $tmpValue = $this->get($key); |
|
| 4718 | unset($array[$key]); |
|
| 4719 | $array += [$key => $tmpValue]; |
|
| 4720 | } |
|
| 4721 | ||
| 4722 | return static::create( |
|
| 4723 | $array, |
|
| 4724 | $this->iteratorClass, |
|
| 4725 | false |
|
| 4726 | ); |
|
| 4727 | } |
|
| 4728 | ||
| 4729 | /** |
|
| 4730 | * Moves the internal iterator position to the next element and returns this element. |
|