| @@ 2188-2204 (lines=17) @@ | ||
| 2185 | * @psalm-return static<TKey,T> |
|
| 2186 | * @psalm-mutation-free |
|
| 2187 | */ |
|
| 2188 | public function firstsImmutable(int $number = null): self |
|
| 2189 | { |
|
| 2190 | $arrayTmp = $this->toArray(); |
|
| 2191 | ||
| 2192 | if ($number === null) { |
|
| 2193 | $array = (array) \array_shift($arrayTmp); |
|
| 2194 | } else { |
|
| 2195 | $number = (int) $number; |
|
| 2196 | $array = \array_splice($arrayTmp, 0, $number); |
|
| 2197 | } |
|
| 2198 | ||
| 2199 | return static::create( |
|
| 2200 | $array, |
|
| 2201 | $this->iteratorClass, |
|
| 2202 | false |
|
| 2203 | ); |
|
| 2204 | } |
|
| 2205 | ||
| 2206 | /** |
|
| 2207 | * Get the first value(s) from the current array. |
|
| @@ 2218-2234 (lines=17) @@ | ||
| 2215 | * @psalm-return static<TKey,T> |
|
| 2216 | * @psalm-mutation-free |
|
| 2217 | */ |
|
| 2218 | public function firstsKeys(int $number = null): self |
|
| 2219 | { |
|
| 2220 | $arrayTmp = $this->keys()->toArray(); |
|
| 2221 | ||
| 2222 | if ($number === null) { |
|
| 2223 | $array = (array) \array_shift($arrayTmp); |
|
| 2224 | } else { |
|
| 2225 | $number = (int) $number; |
|
| 2226 | $array = \array_splice($arrayTmp, 0, $number); |
|
| 2227 | } |
|
| 2228 | ||
| 2229 | return static::create( |
|
| 2230 | $array, |
|
| 2231 | $this->iteratorClass, |
|
| 2232 | false |
|
| 2233 | ); |
|
| 2234 | } |
|
| 2235 | ||
| 2236 | /** |
|
| 2237 | * Get and rmove the first value(s) from the current array. |
|