Code Duplication    Length = 22-22 lines in 2 locations

src/Arrayy.php 2 locations

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