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