| @@ 4512-4527 (lines=16) @@ | ||
| 4509 | * @psalm-return static<TKey,T> |
|
| 4510 | * @psalm-mutation-free |
|
| 4511 | */ |
|
| 4512 | public function moveElementToFirstPlace($key): self |
|
| 4513 | { |
|
| 4514 | $array = $this->toArray(); |
|
| 4515 | ||
| 4516 | if ($this->offsetExists($key)) { |
|
| 4517 | $tmpValue = $this->get($key); |
|
| 4518 | unset($array[$key]); |
|
| 4519 | $array = [$key => $tmpValue] + $array; |
|
| 4520 | } |
|
| 4521 | ||
| 4522 | return static::create( |
|
| 4523 | $array, |
|
| 4524 | $this->iteratorClass, |
|
| 4525 | false |
|
| 4526 | ); |
|
| 4527 | } |
|
| 4528 | ||
| 4529 | /** |
|
| 4530 | * Move an array element to the last place. |
|
| @@ 4543-4558 (lines=16) @@ | ||
| 4540 | * @psalm-return static<TKey,T> |
|
| 4541 | * @psalm-mutation-free |
|
| 4542 | */ |
|
| 4543 | public function moveElementToLastPlace($key): self |
|
| 4544 | { |
|
| 4545 | $array = $this->toArray(); |
|
| 4546 | ||
| 4547 | if ($this->offsetExists($key)) { |
|
| 4548 | $tmpValue = $this->get($key); |
|
| 4549 | unset($array[$key]); |
|
| 4550 | $array += [$key => $tmpValue]; |
|
| 4551 | } |
|
| 4552 | ||
| 4553 | return static::create( |
|
| 4554 | $array, |
|
| 4555 | $this->iteratorClass, |
|
| 4556 | false |
|
| 4557 | ); |
|
| 4558 | } |
|
| 4559 | ||
| 4560 | /** |
|
| 4561 | * Moves the internal iterator position to the next element and returns this element. |
|