| @@ 2409-2424 (lines=16) @@ | ||
| 2406 | * @psalm-return static<TKey,T> |
|
| 2407 | * @psalm-mutation-free |
|
| 2408 | */ |
|
| 2409 | public function firstsImmutable(int $number = null): self |
|
| 2410 | { |
|
| 2411 | $arrayTmp = $this->toArray(); |
|
| 2412 | ||
| 2413 | if ($number === null) { |
|
| 2414 | $array = (array) \array_shift($arrayTmp); |
|
| 2415 | } else { |
|
| 2416 | $array = \array_splice($arrayTmp, 0, $number); |
|
| 2417 | } |
|
| 2418 | ||
| 2419 | return static::create( |
|
| 2420 | $array, |
|
| 2421 | $this->iteratorClass, |
|
| 2422 | false |
|
| 2423 | ); |
|
| 2424 | } |
|
| 2425 | ||
| 2426 | /** |
|
| 2427 | * Get the first value(s) from the current array. |
|
| @@ 2438-2453 (lines=16) @@ | ||
| 2435 | * @psalm-return static<TKey,T> |
|
| 2436 | * @psalm-mutation-free |
|
| 2437 | */ |
|
| 2438 | public function firstsKeys(int $number = null): self |
|
| 2439 | { |
|
| 2440 | $arrayTmp = $this->keys()->toArray(); |
|
| 2441 | ||
| 2442 | if ($number === null) { |
|
| 2443 | $array = (array) \array_shift($arrayTmp); |
|
| 2444 | } else { |
|
| 2445 | $array = \array_splice($arrayTmp, 0, $number); |
|
| 2446 | } |
|
| 2447 | ||
| 2448 | return static::create( |
|
| 2449 | $array, |
|
| 2450 | $this->iteratorClass, |
|
| 2451 | false |
|
| 2452 | ); |
|
| 2453 | } |
|
| 2454 | ||
| 2455 | /** |
|
| 2456 | * Get and rmove the first value(s) from the current array. |
|
| @@ 5027-5041 (lines=15) @@ | ||
| 5024 | * @psalm-return static<TKey,T> |
|
| 5025 | * @psalm-mutation-free |
|
| 5026 | */ |
|
| 5027 | public function replaceOneValue($search, $replacement = ''): self |
|
| 5028 | { |
|
| 5029 | $array = $this->toArray(); |
|
| 5030 | $key = \array_search($search, $array, true); |
|
| 5031 | ||
| 5032 | if ($key !== false) { |
|
| 5033 | $array[$key] = $replacement; |
|
| 5034 | } |
|
| 5035 | ||
| 5036 | return static::create( |
|
| 5037 | $array, |
|
| 5038 | $this->iteratorClass, |
|
| 5039 | false |
|
| 5040 | ); |
|
| 5041 | } |
|
| 5042 | ||
| 5043 | /** |
|
| 5044 | * Replace values in the current array. |
|