@@ 2127-2148 (lines=22) @@ | ||
2124 | * @phpstan-return static<TKey,T> |
|
2125 | * @psalm-mutation-free |
|
2126 | */ |
|
2127 | public function diff(array ...$array): self |
|
2128 | { |
|
2129 | if (\count($array) > 1) { |
|
2130 | $array = \array_merge([], ...$array); |
|
2131 | } else { |
|
2132 | $array = $array[0]; |
|
2133 | } |
|
2134 | ||
2135 | $generator = function () use ($array): \Generator { |
|
2136 | foreach ($this->getGenerator() as $key => $value) { |
|
2137 | if (\in_array($value, $array, true) === 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 keys are only in the current array. |
|
@@ 2162-2183 (lines=22) @@ | ||
2159 | * @phpstan-return static<TKey,T> |
|
2160 | * @psalm-mutation-free |
|
2161 | */ |
|
2162 | public function diffKey(array ...$array): self |
|
2163 | { |
|
2164 | if (\count($array) > 1) { |
|
2165 | $array = \array_replace([], ...$array); |
|
2166 | } else { |
|
2167 | $array = $array[0]; |
|
2168 | } |
|
2169 | ||
2170 | $generator = function () use ($array): \Generator { |
|
2171 | foreach ($this->getGenerator() as $key => $value) { |
|
2172 | if (\array_key_exists($key, $array) === false) { |
|
2173 | yield $key => $value; |
|
2174 | } |
|
2175 | } |
|
2176 | }; |
|
2177 | ||
2178 | return static::create( |
|
2179 | $generator, |
|
2180 | $this->iteratorClass, |
|
2181 | false |
|
2182 | ); |
|
2183 | } |
|
2184 | ||
2185 | /** |
|
2186 | * Return elements where the values and keys are only in the current array. |