@@ 3238-3253 (lines=16) @@ | ||
3235 | * @return static |
|
3236 | * <p>(Immutable)</p> |
|
3237 | */ |
|
3238 | public function moveElementToFirstPlace($key): self |
|
3239 | { |
|
3240 | $array = $this->getArray(); |
|
3241 | ||
3242 | if ($this->offsetExists($key)) { |
|
3243 | $tmpValue = $this->get($key); |
|
3244 | unset($array[$key]); |
|
3245 | $array = [$key => $tmpValue] + $array; |
|
3246 | } |
|
3247 | ||
3248 | return static::create( |
|
3249 | $array, |
|
3250 | $this->iteratorClass, |
|
3251 | false |
|
3252 | ); |
|
3253 | } |
|
3254 | ||
3255 | /** |
|
3256 | * Move an array element to the last place. |
|
@@ 3266-3281 (lines=16) @@ | ||
3263 | * @return static |
|
3264 | * <p>(Immutable)</p> |
|
3265 | */ |
|
3266 | public function moveElementToLastPlace($key): self |
|
3267 | { |
|
3268 | $array = $this->getArray(); |
|
3269 | ||
3270 | if ($this->offsetExists($key)) { |
|
3271 | $tmpValue = $this->get($key); |
|
3272 | unset($array[$key]); |
|
3273 | $array += [$key => $tmpValue]; |
|
3274 | } |
|
3275 | ||
3276 | return static::create( |
|
3277 | $array, |
|
3278 | $this->iteratorClass, |
|
3279 | false |
|
3280 | ); |
|
3281 | } |
|
3282 | ||
3283 | /** |
|
3284 | * Moves the internal iterator position to the next element and returns this element. |