Code Duplication    Length = 13-14 lines in 3 locations

src/Arrayy.php 3 locations

@@ 5688-5700 (lines=13) @@
5685
     * @phpstan-return static<TKey,T>
5686
     * @psalm-mutation-free
5687
     */
5688
    public function replaceAllKeys(array $keys): self
5689
    {
5690
        $data = \array_combine($keys, $this->toArray());
5691
        if ($data === false) {
5692
            $data = [];
5693
        }
5694
5695
        return static::create(
5696
            $data,
5697
            $this->iteratorClass,
5698
            false
5699
        );
5700
    }
5701
5702
    /**
5703
     * Create an array using the current array as keys and the other array as values.
@@ 5731-5743 (lines=13) @@
5728
     * @phpstan-return static<TKey,T>
5729
     * @psalm-mutation-free
5730
     */
5731
    public function replaceAllValues(array $array): self
5732
    {
5733
        $data = \array_combine($this->toArray(), $array);
5734
        if ($data === false) {
5735
            $data = [];
5736
        }
5737
5738
        return static::create(
5739
            $data,
5740
            $this->iteratorClass,
5741
            false
5742
        );
5743
    }
5744
5745
    /**
5746
     * Replace the keys in an array with another set.
@@ 5761-5774 (lines=14) @@
5758
     * @phpstan-return static<TKey,T>
5759
     * @psalm-mutation-free
5760
     */
5761
    public function replaceKeys(array $keys): self
5762
    {
5763
        $values = \array_values($this->toArray());
5764
        $result = \array_combine($keys, $values);
5765
        if ($result === false) {
5766
            $result = [];
5767
        }
5768
5769
        return static::create(
5770
            $result,
5771
            $this->iteratorClass,
5772
            false
5773
        );
5774
    }
5775
5776
    /**
5777
     * Replace the first matched value in an array.