| @@ 3053-3068 (lines=16) @@ | ||
| 3050 | * @return static |
|
| 3051 | * <p>(Immutable)</p> |
|
| 3052 | */ |
|
| 3053 | public function moveElementToFirstPlace($key): self |
|
| 3054 | { |
|
| 3055 | $array = $this->getArray(); |
|
| 3056 | ||
| 3057 | if ($this->offsetExists($key)) { |
|
| 3058 | $tmpValue = $this->get($key); |
|
| 3059 | unset($array[$key]); |
|
| 3060 | $array = [$key => $tmpValue] + $array; |
|
| 3061 | } |
|
| 3062 | ||
| 3063 | return static::create( |
|
| 3064 | $array, |
|
| 3065 | $this->iteratorClass, |
|
| 3066 | false |
|
| 3067 | ); |
|
| 3068 | } |
|
| 3069 | ||
| 3070 | /** |
|
| 3071 | * Move an array element to the last place. |
|
| @@ 3081-3096 (lines=16) @@ | ||
| 3078 | * @return static |
|
| 3079 | * <p>(Immutable)</p> |
|
| 3080 | */ |
|
| 3081 | public function moveElementToLastPlace($key): self |
|
| 3082 | { |
|
| 3083 | $array = $this->getArray(); |
|
| 3084 | ||
| 3085 | if ($this->offsetExists($key)) { |
|
| 3086 | $tmpValue = $this->get($key); |
|
| 3087 | unset($array[$key]); |
|
| 3088 | $array += [$key => $tmpValue]; |
|
| 3089 | } |
|
| 3090 | ||
| 3091 | return static::create( |
|
| 3092 | $array, |
|
| 3093 | $this->iteratorClass, |
|
| 3094 | false |
|
| 3095 | ); |
|
| 3096 | } |
|
| 3097 | ||
| 3098 | /** |
|
| 3099 | * Get a subset of the items from the given array. |
|