Code Duplication    Length = 22-22 lines in 2 locations

src/Arrayy.php 2 locations

@@ 2065-2086 (lines=22) @@
2062
     * @psalm-return static<TKey,T>
2063
     * @psalm-mutation-free
2064
     */
2065
    public function diff(array ...$array): self
2066
    {
2067
        if (\count($array) > 1) {
2068
            $array = \array_merge([], ...$array);
2069
        } else {
2070
            $array = $array[0];
2071
        }
2072
2073
        $generator = function () use ($array): \Generator {
2074
            foreach ($this->getGenerator() as $key => $value) {
2075
                if (\in_array($value, $array, true) === false) {
2076
                    yield $key => $value;
2077
                }
2078
            }
2079
        };
2080
2081
        return static::create(
2082
            $generator,
2083
            $this->iteratorClass,
2084
            false
2085
        );
2086
    }
2087
2088
    /**
2089
     * Return elements where the keys are only in the current array.
@@ 2100-2121 (lines=22) @@
2097
     * @psalm-return static<TKey,T>
2098
     * @psalm-mutation-free
2099
     */
2100
    public function diffKey(array ...$array): self
2101
    {
2102
        if (\count($array) > 1) {
2103
            $array = \array_replace([], ...$array);
2104
        } else {
2105
            $array = $array[0];
2106
        }
2107
2108
        $generator = function () use ($array): \Generator {
2109
            foreach ($this->getGenerator() as $key => $value) {
2110
                if (\array_key_exists($key, $array) === false) {
2111
                    yield $key => $value;
2112
                }
2113
            }
2114
        };
2115
2116
        return static::create(
2117
            $generator,
2118
            $this->iteratorClass,
2119
            false
2120
        );
2121
    }
2122
2123
    /**
2124
     * Return elements where the values and keys are only in the current array.