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