| @@ 4299-4314 (lines=16) @@ | ||
| 4296 | * |
|
| 4297 | * @phpstan-param \Closure(T=,TKey=):bool $closure |
|
| 4298 | */ |
|
| 4299 | public function matches(\Closure $closure): bool |
|
| 4300 | { |
|
| 4301 | if ($this->count() === 0) { |
|
| 4302 | return false; |
|
| 4303 | } |
|
| 4304 | ||
| 4305 | foreach ($this->getGenerator() as $key => $value) { |
|
| 4306 | $value = $closure($value, $key); |
|
| 4307 | ||
| 4308 | if ($value === false) { |
|
| 4309 | return false; |
|
| 4310 | } |
|
| 4311 | } |
|
| 4312 | ||
| 4313 | return true; |
|
| 4314 | } |
|
| 4315 | ||
| 4316 | /** |
|
| 4317 | * Check if any item in the current array matches a truth test. |
|
| @@ 4332-4347 (lines=16) @@ | ||
| 4329 | * |
|
| 4330 | * @phpstan-param \Closure(T=,TKey=):bool $closure |
|
| 4331 | */ |
|
| 4332 | public function matchesAny(\Closure $closure): bool |
|
| 4333 | { |
|
| 4334 | if ($this->count() === 0) { |
|
| 4335 | return false; |
|
| 4336 | } |
|
| 4337 | ||
| 4338 | foreach ($this->getGenerator() as $key => $value) { |
|
| 4339 | $value = $closure($value, $key); |
|
| 4340 | ||
| 4341 | if ($value === true) { |
|
| 4342 | return true; |
|
| 4343 | } |
|
| 4344 | } |
|
| 4345 | ||
| 4346 | return false; |
|
| 4347 | } |
|
| 4348 | ||
| 4349 | /** |
|
| 4350 | * Get the max value from an array. |
|