Code Duplication    Length = 15-16 lines in 3 locations

src/Arrayy.php 3 locations

@@ 2620-2635 (lines=16) @@
2617
     * @psalm-return static<TKey,T>
2618
     * @psalm-mutation-free
2619
     */
2620
    public function firstsImmutable(int $number = null): self
2621
    {
2622
        $arrayTmp = $this->toArray();
2623
2624
        if ($number === null) {
2625
            $array = (array) \array_shift($arrayTmp);
2626
        } else {
2627
            $array = \array_splice($arrayTmp, 0, $number);
2628
        }
2629
2630
        return static::create(
2631
            $array,
2632
            $this->iteratorClass,
2633
            false
2634
        );
2635
    }
2636
2637
    /**
2638
     * Get the first value(s) from the current array.
@@ 2649-2664 (lines=16) @@
2646
     * @psalm-return static<TKey,T>
2647
     * @psalm-mutation-free
2648
     */
2649
    public function firstsKeys(int $number = null): self
2650
    {
2651
        $arrayTmp = $this->keys()->toArray();
2652
2653
        if ($number === null) {
2654
            $array = (array) \array_shift($arrayTmp);
2655
        } else {
2656
            $array = \array_splice($arrayTmp, 0, $number);
2657
        }
2658
2659
        return static::create(
2660
            $array,
2661
            $this->iteratorClass,
2662
            false
2663
        );
2664
    }
2665
2666
    /**
2667
     * Get and remove the first value(s) from the current array.
@@ 5591-5605 (lines=15) @@
5588
     * @psalm-return static<TKey,T>
5589
     * @psalm-mutation-free
5590
     */
5591
    public function replaceOneValue($search, $replacement = ''): self
5592
    {
5593
        $array = $this->toArray();
5594
        $key = \array_search($search, $array, true);
5595
5596
        if ($key !== false) {
5597
            $array[$key] = $replacement;
5598
        }
5599
5600
        return static::create(
5601
            $array,
5602
            $this->iteratorClass,
5603
            false
5604
        );
5605
    }
5606
5607
    /**
5608
     * Replace values in the current array.