| @@ 3850-3865 (lines=16) @@ | ||
| 3847 | * @psalm-return static<TKey,T> | |
| 3848 | * @psalm-mutation-free | |
| 3849 | */ | |
| 3850 | public function moveElementToFirstPlace($key): self | |
| 3851 |     { | |
| 3852 | $array = $this->toArray(); | |
| 3853 | ||
| 3854 |         if ($this->offsetExists($key)) { | |
| 3855 | $tmpValue = $this->get($key); | |
| 3856 | unset($array[$key]); | |
| 3857 | $array = [$key => $tmpValue] + $array; | |
| 3858 | } | |
| 3859 | ||
| 3860 | return static::create( | |
| 3861 | $array, | |
| 3862 | $this->iteratorClass, | |
| 3863 | false | |
| 3864 | ); | |
| 3865 | } | |
| 3866 | ||
| 3867 | /** | |
| 3868 | * Move an array element to the last place. | |
| @@ 3881-3896 (lines=16) @@ | ||
| 3878 | * @psalm-return static<TKey,T> | |
| 3879 | * @psalm-mutation-free | |
| 3880 | */ | |
| 3881 | public function moveElementToLastPlace($key): self | |
| 3882 |     { | |
| 3883 | $array = $this->toArray(); | |
| 3884 | ||
| 3885 |         if ($this->offsetExists($key)) { | |
| 3886 | $tmpValue = $this->get($key); | |
| 3887 | unset($array[$key]); | |
| 3888 | $array += [$key => $tmpValue]; | |
| 3889 | } | |
| 3890 | ||
| 3891 | return static::create( | |
| 3892 | $array, | |
| 3893 | $this->iteratorClass, | |
| 3894 | false | |
| 3895 | ); | |
| 3896 | } | |
| 3897 | ||
| 3898 | /** | |
| 3899 | * Moves the internal iterator position to the next element and returns this element. | |