Code Duplication    Length = 13-14 lines in 3 locations

src/Arrayy.php 3 locations

@@ 5650-5662 (lines=13) @@
5647
     * @phpstan-return static<TKey,T>
5648
     * @psalm-mutation-free
5649
     */
5650
    public function replaceAllKeys(array $keys): self
5651
    {
5652
        $data = \array_combine($keys, $this->toArray());
5653
        if ($data === false) {
5654
            $data = [];
5655
        }
5656
5657
        return static::create(
5658
            $data,
5659
            $this->iteratorClass,
5660
            false
5661
        );
5662
    }
5663
5664
    /**
5665
     * Create an array using the current array as keys and the other array as values.
@@ 5693-5705 (lines=13) @@
5690
     * @phpstan-return static<TKey,T>
5691
     * @psalm-mutation-free
5692
     */
5693
    public function replaceAllValues(array $array): self
5694
    {
5695
        $data = \array_combine($this->toArray(), $array);
5696
        if ($data === false) {
5697
            $data = [];
5698
        }
5699
5700
        return static::create(
5701
            $data,
5702
            $this->iteratorClass,
5703
            false
5704
        );
5705
    }
5706
5707
    /**
5708
     * Replace the keys in an array with another set.
@@ 5723-5736 (lines=14) @@
5720
     * @phpstan-return static<TKey,T>
5721
     * @psalm-mutation-free
5722
     */
5723
    public function replaceKeys(array $keys): self
5724
    {
5725
        $values = \array_values($this->toArray());
5726
        $result = \array_combine($keys, $values);
5727
        if ($result === false) {
5728
            $result = [];
5729
        }
5730
5731
        return static::create(
5732
            $result,
5733
            $this->iteratorClass,
5734
            false
5735
        );
5736
    }
5737
5738
    /**
5739
     * Replace the first matched value in an array.