| @@ 3169-3184 (lines=16) @@ | ||
| 3166 | * @return static | |
| 3167 | * <p>(Immutable)</p> | |
| 3168 | */ | |
| 3169 | public function moveElementToFirstPlace($key): self | |
| 3170 |     { | |
| 3171 | $array = $this->getArray(); | |
| 3172 | ||
| 3173 |         if ($this->offsetExists($key)) { | |
| 3174 | $tmpValue = $this->get($key); | |
| 3175 | unset($array[$key]); | |
| 3176 | $array = [$key => $tmpValue] + $array; | |
| 3177 | } | |
| 3178 | ||
| 3179 | return static::create( | |
| 3180 | $array, | |
| 3181 | $this->iteratorClass, | |
| 3182 | false | |
| 3183 | ); | |
| 3184 | } | |
| 3185 | ||
| 3186 | /** | |
| 3187 | * Move an array element to the last place. | |
| @@ 3197-3212 (lines=16) @@ | ||
| 3194 | * @return static | |
| 3195 | * <p>(Immutable)</p> | |
| 3196 | */ | |
| 3197 | public function moveElementToLastPlace($key): self | |
| 3198 |     { | |
| 3199 | $array = $this->getArray(); | |
| 3200 | ||
| 3201 |         if ($this->offsetExists($key)) { | |
| 3202 | $tmpValue = $this->get($key); | |
| 3203 | unset($array[$key]); | |
| 3204 | $array += [$key => $tmpValue]; | |
| 3205 | } | |
| 3206 | ||
| 3207 | return static::create( | |
| 3208 | $array, | |
| 3209 | $this->iteratorClass, | |
| 3210 | false | |
| 3211 | ); | |
| 3212 | } | |
| 3213 | ||
| 3214 | /** | |
| 3215 | * Moves the internal iterator position to the next element and returns this element. | |