@@ 4599-4614 (lines=16) @@ | ||
4596 | * @psalm-return static<TKey,T> |
|
4597 | * @psalm-mutation-free |
|
4598 | */ |
|
4599 | public function moveElementToFirstPlace($key): self |
|
4600 | { |
|
4601 | $array = $this->toArray(); |
|
4602 | ||
4603 | if ($this->offsetExists($key)) { |
|
4604 | $tmpValue = $this->get($key); |
|
4605 | unset($array[$key]); |
|
4606 | $array = [$key => $tmpValue] + $array; |
|
4607 | } |
|
4608 | ||
4609 | return static::create( |
|
4610 | $array, |
|
4611 | $this->iteratorClass, |
|
4612 | false |
|
4613 | ); |
|
4614 | } |
|
4615 | ||
4616 | /** |
|
4617 | * Move an array element to the last place. |
|
@@ 4630-4645 (lines=16) @@ | ||
4627 | * @psalm-return static<TKey,T> |
|
4628 | * @psalm-mutation-free |
|
4629 | */ |
|
4630 | public function moveElementToLastPlace($key): self |
|
4631 | { |
|
4632 | $array = $this->toArray(); |
|
4633 | ||
4634 | if ($this->offsetExists($key)) { |
|
4635 | $tmpValue = $this->get($key); |
|
4636 | unset($array[$key]); |
|
4637 | $array += [$key => $tmpValue]; |
|
4638 | } |
|
4639 | ||
4640 | return static::create( |
|
4641 | $array, |
|
4642 | $this->iteratorClass, |
|
4643 | false |
|
4644 | ); |
|
4645 | } |
|
4646 | ||
4647 | /** |
|
4648 | * Moves the internal iterator position to the next element and returns this element. |