Code Duplication    Length = 13-14 lines in 3 locations

src/Arrayy.php 3 locations

@@ 5597-5609 (lines=13) @@
5594
     * @psalm-return static<TKey,T>
5595
     * @psalm-mutation-free
5596
     */
5597
    public function replaceAllKeys(array $keys): self
5598
    {
5599
        $data = \array_combine($keys, $this->toArray());
5600
        if ($data === false) {
5601
            $data = [];
5602
        }
5603
5604
        return static::create(
5605
            $data,
5606
            $this->iteratorClass,
5607
            false
5608
        );
5609
    }
5610
5611
    /**
5612
     * Create an array using the current array as keys and the other array as values.
@@ 5640-5652 (lines=13) @@
5637
     * @psalm-return static<TKey,T>
5638
     * @psalm-mutation-free
5639
     */
5640
    public function replaceAllValues(array $array): self
5641
    {
5642
        $data = \array_combine($this->toArray(), $array);
5643
        if ($data === false) {
5644
            $data = [];
5645
        }
5646
5647
        return static::create(
5648
            $data,
5649
            $this->iteratorClass,
5650
            false
5651
        );
5652
    }
5653
5654
    /**
5655
     * Replace the keys in an array with another set.
@@ 5670-5683 (lines=14) @@
5667
     * @psalm-return static<TKey,T>
5668
     * @psalm-mutation-free
5669
     */
5670
    public function replaceKeys(array $keys): self
5671
    {
5672
        $values = \array_values($this->toArray());
5673
        $result = \array_combine($keys, $values);
5674
        if ($result === false) {
5675
            $result = [];
5676
        }
5677
5678
        return static::create(
5679
            $result,
5680
            $this->iteratorClass,
5681
            false
5682
        );
5683
    }
5684
5685
    /**
5686
     * Replace the first matched value in an array.