@@ 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. |
|
@@ 5014-5028 (lines=15) @@ | ||
5011 | * @psalm-return static<TKey,T> |
|
5012 | * @psalm-mutation-free |
|
5013 | */ |
|
5014 | public function replaceOneValue($search, $replacement = ''): self |
|
5015 | { |
|
5016 | $array = $this->toArray(); |
|
5017 | $key = \array_search($search, $array, true); |
|
5018 | ||
5019 | if ($key !== false) { |
|
5020 | $array[$key] = $replacement; |
|
5021 | } |
|
5022 | ||
5023 | return static::create( |
|
5024 | $array, |
|
5025 | $this->iteratorClass, |
|
5026 | false |
|
5027 | ); |
|
5028 | } |
|
5029 | ||
5030 | /** |
|
5031 | * Replace values in the current array. |