| @@ 2462-2477 (lines=16) @@ | ||
| 2459 | * @psalm-return static<TKey,T> |
|
| 2460 | * @psalm-mutation-free |
|
| 2461 | */ |
|
| 2462 | public function firstsImmutable(int $number = null): self |
|
| 2463 | { |
|
| 2464 | $arrayTmp = $this->toArray(); |
|
| 2465 | ||
| 2466 | if ($number === null) { |
|
| 2467 | $array = (array) \array_shift($arrayTmp); |
|
| 2468 | } else { |
|
| 2469 | $array = \array_splice($arrayTmp, 0, $number); |
|
| 2470 | } |
|
| 2471 | ||
| 2472 | return static::create( |
|
| 2473 | $array, |
|
| 2474 | $this->iteratorClass, |
|
| 2475 | false |
|
| 2476 | ); |
|
| 2477 | } |
|
| 2478 | ||
| 2479 | /** |
|
| 2480 | * Get the first value(s) from the current array. |
|
| @@ 2491-2506 (lines=16) @@ | ||
| 2488 | * @psalm-return static<TKey,T> |
|
| 2489 | * @psalm-mutation-free |
|
| 2490 | */ |
|
| 2491 | public function firstsKeys(int $number = null): self |
|
| 2492 | { |
|
| 2493 | $arrayTmp = $this->keys()->toArray(); |
|
| 2494 | ||
| 2495 | if ($number === null) { |
|
| 2496 | $array = (array) \array_shift($arrayTmp); |
|
| 2497 | } else { |
|
| 2498 | $array = \array_splice($arrayTmp, 0, $number); |
|
| 2499 | } |
|
| 2500 | ||
| 2501 | return static::create( |
|
| 2502 | $array, |
|
| 2503 | $this->iteratorClass, |
|
| 2504 | false |
|
| 2505 | ); |
|
| 2506 | } |
|
| 2507 | ||
| 2508 | /** |
|
| 2509 | * Get and rmove the first value(s) from the current array. |
|
| @@ 5138-5152 (lines=15) @@ | ||
| 5135 | * @psalm-return static<TKey,T> |
|
| 5136 | * @psalm-mutation-free |
|
| 5137 | */ |
|
| 5138 | public function replaceOneValue($search, $replacement = ''): self |
|
| 5139 | { |
|
| 5140 | $array = $this->toArray(); |
|
| 5141 | $key = \array_search($search, $array, true); |
|
| 5142 | ||
| 5143 | if ($key !== false) { |
|
| 5144 | $array[$key] = $replacement; |
|
| 5145 | } |
|
| 5146 | ||
| 5147 | return static::create( |
|
| 5148 | $array, |
|
| 5149 | $this->iteratorClass, |
|
| 5150 | false |
|
| 5151 | ); |
|
| 5152 | } |
|
| 5153 | ||
| 5154 | /** |
|
| 5155 | * Replace values in the current array. |
|