| @@ 2237-2253 (lines=17) @@ | ||
| 2234 | * @psalm-return static<TKey,T> |
|
| 2235 | * @psalm-mutation-free |
|
| 2236 | */ |
|
| 2237 | public function firstsImmutable(int $number = null): self |
|
| 2238 | { |
|
| 2239 | $arrayTmp = $this->toArray(); |
|
| 2240 | ||
| 2241 | if ($number === null) { |
|
| 2242 | $array = (array) \array_shift($arrayTmp); |
|
| 2243 | } else { |
|
| 2244 | $number = (int) $number; |
|
| 2245 | $array = \array_splice($arrayTmp, 0, $number); |
|
| 2246 | } |
|
| 2247 | ||
| 2248 | return static::create( |
|
| 2249 | $array, |
|
| 2250 | $this->iteratorClass, |
|
| 2251 | false |
|
| 2252 | ); |
|
| 2253 | } |
|
| 2254 | ||
| 2255 | /** |
|
| 2256 | * Get the first value(s) from the current array. |
|
| @@ 2267-2283 (lines=17) @@ | ||
| 2264 | * @psalm-return static<TKey,T> |
|
| 2265 | * @psalm-mutation-free |
|
| 2266 | */ |
|
| 2267 | public function firstsKeys(int $number = null): self |
|
| 2268 | { |
|
| 2269 | $arrayTmp = $this->keys()->toArray(); |
|
| 2270 | ||
| 2271 | if ($number === null) { |
|
| 2272 | $array = (array) \array_shift($arrayTmp); |
|
| 2273 | } else { |
|
| 2274 | $number = (int) $number; |
|
| 2275 | $array = \array_splice($arrayTmp, 0, $number); |
|
| 2276 | } |
|
| 2277 | ||
| 2278 | return static::create( |
|
| 2279 | $array, |
|
| 2280 | $this->iteratorClass, |
|
| 2281 | false |
|
| 2282 | ); |
|
| 2283 | } |
|
| 2284 | ||
| 2285 | /** |
|
| 2286 | * Get and rmove the first value(s) from the current array. |
|