| @@ 4268-4283 (lines=16) @@ | ||
| 4265 | * |
|
| 4266 | * @phpstan-param \Closure(T=,TKey=):bool $closure |
|
| 4267 | */ |
|
| 4268 | public function matches(\Closure $closure): bool |
|
| 4269 | { |
|
| 4270 | if ($this->count() === 0) { |
|
| 4271 | return false; |
|
| 4272 | } |
|
| 4273 | ||
| 4274 | foreach ($this->getGenerator() as $key => $value) { |
|
| 4275 | $value = $closure($value, $key); |
|
| 4276 | ||
| 4277 | if ($value === false) { |
|
| 4278 | return false; |
|
| 4279 | } |
|
| 4280 | } |
|
| 4281 | ||
| 4282 | return true; |
|
| 4283 | } |
|
| 4284 | ||
| 4285 | /** |
|
| 4286 | * Check if any item in the current array matches a truth test. |
|
| @@ 4301-4316 (lines=16) @@ | ||
| 4298 | * |
|
| 4299 | * @phpstan-param \Closure(T=,TKey=):bool $closure |
|
| 4300 | */ |
|
| 4301 | public function matchesAny(\Closure $closure): bool |
|
| 4302 | { |
|
| 4303 | if ($this->count() === 0) { |
|
| 4304 | return false; |
|
| 4305 | } |
|
| 4306 | ||
| 4307 | foreach ($this->getGenerator() as $key => $value) { |
|
| 4308 | $value = $closure($value, $key); |
|
| 4309 | ||
| 4310 | if ($value === true) { |
|
| 4311 | return true; |
|
| 4312 | } |
|
| 4313 | } |
|
| 4314 | ||
| 4315 | return false; |
|
| 4316 | } |
|
| 4317 | ||
| 4318 | /** |
|
| 4319 | * Get the max value from an array. |
|