Code Duplication    Length = 13-14 lines in 3 locations

src/Arrayy.php 3 locations

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