@@ 2108-2129 (lines=22) @@ | ||
2105 | * @phpstan-return static<TKey,T> |
|
2106 | * @psalm-mutation-free |
|
2107 | */ |
|
2108 | public function diff(array ...$array): self |
|
2109 | { |
|
2110 | if (\count($array) > 1) { |
|
2111 | $array = \array_merge([], ...$array); |
|
2112 | } else { |
|
2113 | $array = $array[0]; |
|
2114 | } |
|
2115 | ||
2116 | $generator = function () use ($array): \Generator { |
|
2117 | foreach ($this->getGenerator() as $key => $value) { |
|
2118 | if (\in_array($value, $array, true) === false) { |
|
2119 | yield $key => $value; |
|
2120 | } |
|
2121 | } |
|
2122 | }; |
|
2123 | ||
2124 | return static::create( |
|
2125 | $generator, |
|
2126 | $this->iteratorClass, |
|
2127 | false |
|
2128 | ); |
|
2129 | } |
|
2130 | ||
2131 | /** |
|
2132 | * Return elements where the keys are only in the current array. |
|
@@ 2143-2164 (lines=22) @@ | ||
2140 | * @phpstan-return static<TKey,T> |
|
2141 | * @psalm-mutation-free |
|
2142 | */ |
|
2143 | public function diffKey(array ...$array): self |
|
2144 | { |
|
2145 | if (\count($array) > 1) { |
|
2146 | $array = \array_replace([], ...$array); |
|
2147 | } else { |
|
2148 | $array = $array[0]; |
|
2149 | } |
|
2150 | ||
2151 | $generator = function () use ($array): \Generator { |
|
2152 | foreach ($this->getGenerator() as $key => $value) { |
|
2153 | if (\array_key_exists($key, $array) === false) { |
|
2154 | yield $key => $value; |
|
2155 | } |
|
2156 | } |
|
2157 | }; |
|
2158 | ||
2159 | return static::create( |
|
2160 | $generator, |
|
2161 | $this->iteratorClass, |
|
2162 | false |
|
2163 | ); |
|
2164 | } |
|
2165 | ||
2166 | /** |
|
2167 | * Return elements where the values and keys are only in the current array. |