| @@ 3158-3173 (lines=16) @@ | ||
| 3155 | * @return static |
|
| 3156 | * <p>(Immutable)</p> |
|
| 3157 | */ |
|
| 3158 | public function moveElementToFirstPlace($key): self |
|
| 3159 | { |
|
| 3160 | $array = $this->getArray(); |
|
| 3161 | ||
| 3162 | if ($this->offsetExists($key)) { |
|
| 3163 | $tmpValue = $this->get($key); |
|
| 3164 | unset($array[$key]); |
|
| 3165 | $array = [$key => $tmpValue] + $array; |
|
| 3166 | } |
|
| 3167 | ||
| 3168 | return static::create( |
|
| 3169 | $array, |
|
| 3170 | $this->iteratorClass, |
|
| 3171 | false |
|
| 3172 | ); |
|
| 3173 | } |
|
| 3174 | ||
| 3175 | /** |
|
| 3176 | * Move an array element to the last place. |
|
| @@ 3186-3201 (lines=16) @@ | ||
| 3183 | * @return static |
|
| 3184 | * <p>(Immutable)</p> |
|
| 3185 | */ |
|
| 3186 | public function moveElementToLastPlace($key): self |
|
| 3187 | { |
|
| 3188 | $array = $this->getArray(); |
|
| 3189 | ||
| 3190 | if ($this->offsetExists($key)) { |
|
| 3191 | $tmpValue = $this->get($key); |
|
| 3192 | unset($array[$key]); |
|
| 3193 | $array += [$key => $tmpValue]; |
|
| 3194 | } |
|
| 3195 | ||
| 3196 | return static::create( |
|
| 3197 | $array, |
|
| 3198 | $this->iteratorClass, |
|
| 3199 | false |
|
| 3200 | ); |
|
| 3201 | } |
|
| 3202 | ||
| 3203 | /** |
|
| 3204 | * Moves the internal iterator position to the next element and returns this element. |
|