| @@ 3367-3382 (lines=16) @@ | ||
| 3364 | * |
|
| 3365 | * @psalm-return static<TKey,T> |
|
| 3366 | */ |
|
| 3367 | public function moveElementToFirstPlace($key): self |
|
| 3368 | { |
|
| 3369 | $array = $this->getArray(); |
|
| 3370 | ||
| 3371 | if ($this->offsetExists($key)) { |
|
| 3372 | $tmpValue = $this->get($key); |
|
| 3373 | unset($array[$key]); |
|
| 3374 | $array = [$key => $tmpValue] + $array; |
|
| 3375 | } |
|
| 3376 | ||
| 3377 | return static::create( |
|
| 3378 | $array, |
|
| 3379 | $this->iteratorClass, |
|
| 3380 | false |
|
| 3381 | ); |
|
| 3382 | } |
|
| 3383 | ||
| 3384 | /** |
|
| 3385 | * Move an array element to the last place. |
|
| @@ 3397-3412 (lines=16) @@ | ||
| 3394 | * |
|
| 3395 | * @psalm-return static<TKey,T> |
|
| 3396 | */ |
|
| 3397 | public function moveElementToLastPlace($key): self |
|
| 3398 | { |
|
| 3399 | $array = $this->getArray(); |
|
| 3400 | ||
| 3401 | if ($this->offsetExists($key)) { |
|
| 3402 | $tmpValue = $this->get($key); |
|
| 3403 | unset($array[$key]); |
|
| 3404 | $array += [$key => $tmpValue]; |
|
| 3405 | } |
|
| 3406 | ||
| 3407 | return static::create( |
|
| 3408 | $array, |
|
| 3409 | $this->iteratorClass, |
|
| 3410 | false |
|
| 3411 | ); |
|
| 3412 | } |
|
| 3413 | ||
| 3414 | /** |
|
| 3415 | * Moves the internal iterator position to the next element and returns this element. |
|