| @@ 4648-4663 (lines=16) @@ | ||
| 4645 | * @phpstan-return static<TKey,T> |
|
| 4646 | * @psalm-mutation-free |
|
| 4647 | */ |
|
| 4648 | public function moveElementToFirstPlace($key): self |
|
| 4649 | { |
|
| 4650 | $array = $this->toArray(); |
|
| 4651 | ||
| 4652 | if ($this->offsetExists($key)) { |
|
| 4653 | $tmpValue = $this->get($key); |
|
| 4654 | unset($array[$key]); |
|
| 4655 | $array = [$key => $tmpValue] + $array; |
|
| 4656 | } |
|
| 4657 | ||
| 4658 | return static::create( |
|
| 4659 | $array, |
|
| 4660 | $this->iteratorClass, |
|
| 4661 | false |
|
| 4662 | ); |
|
| 4663 | } |
|
| 4664 | ||
| 4665 | /** |
|
| 4666 | * Move an array element to the last place. |
|
| @@ 4679-4694 (lines=16) @@ | ||
| 4676 | * @phpstan-return static<TKey,T> |
|
| 4677 | * @psalm-mutation-free |
|
| 4678 | */ |
|
| 4679 | public function moveElementToLastPlace($key): self |
|
| 4680 | { |
|
| 4681 | $array = $this->toArray(); |
|
| 4682 | ||
| 4683 | if ($this->offsetExists($key)) { |
|
| 4684 | $tmpValue = $this->get($key); |
|
| 4685 | unset($array[$key]); |
|
| 4686 | $array += [$key => $tmpValue]; |
|
| 4687 | } |
|
| 4688 | ||
| 4689 | return static::create( |
|
| 4690 | $array, |
|
| 4691 | $this->iteratorClass, |
|
| 4692 | false |
|
| 4693 | ); |
|
| 4694 | } |
|
| 4695 | ||
| 4696 | /** |
|
| 4697 | * Moves the internal iterator position to the next element and returns this element. |
|