Code Duplication    Length = 22-22 lines in 2 locations

src/Arrayy.php 2 locations

@@ 2090-2111 (lines=22) @@
2087
     * @phpstan-return static<TKey,T>
2088
     * @psalm-mutation-free
2089
     */
2090
    public function diff(array ...$array): self
2091
    {
2092
        if (\count($array) > 1) {
2093
            $array = \array_merge([], ...$array);
2094
        } else {
2095
            $array = $array[0];
2096
        }
2097
2098
        $generator = function () use ($array): \Generator {
2099
            foreach ($this->getGenerator() as $key => $value) {
2100
                if (\in_array($value, $array, true) === false) {
2101
                    yield $key => $value;
2102
                }
2103
            }
2104
        };
2105
2106
        return static::create(
2107
            $generator,
2108
            $this->iteratorClass,
2109
            false
2110
        );
2111
    }
2112
2113
    /**
2114
     * Return elements where the keys are only in the current array.
@@ 2125-2146 (lines=22) @@
2122
     * @phpstan-return static<TKey,T>
2123
     * @psalm-mutation-free
2124
     */
2125
    public function diffKey(array ...$array): self
2126
    {
2127
        if (\count($array) > 1) {
2128
            $array = \array_replace([], ...$array);
2129
        } else {
2130
            $array = $array[0];
2131
        }
2132
2133
        $generator = function () use ($array): \Generator {
2134
            foreach ($this->getGenerator() as $key => $value) {
2135
                if (\array_key_exists($key, $array) === false) {
2136
                    yield $key => $value;
2137
                }
2138
            }
2139
        };
2140
2141
        return static::create(
2142
            $generator,
2143
            $this->iteratorClass,
2144
            false
2145
        );
2146
    }
2147
2148
    /**
2149
     * Return elements where the values and keys are only in the current array.