| @@ 4319-4334 (lines=16) @@ | ||
| 4316 | * |
|
| 4317 | * @phpstan-param \Closure(T=,TKey=):bool $closure |
|
| 4318 | */ |
|
| 4319 | public function matches(\Closure $closure): bool |
|
| 4320 | { |
|
| 4321 | if ($this->count() === 0) { |
|
| 4322 | return false; |
|
| 4323 | } |
|
| 4324 | ||
| 4325 | foreach ($this->getGenerator() as $key => $value) { |
|
| 4326 | $value = $closure($value, $key); |
|
| 4327 | ||
| 4328 | if ($value === false) { |
|
| 4329 | return false; |
|
| 4330 | } |
|
| 4331 | } |
|
| 4332 | ||
| 4333 | return true; |
|
| 4334 | } |
|
| 4335 | ||
| 4336 | /** |
|
| 4337 | * Check if any item in the current array matches a truth test. |
|
| @@ 4352-4367 (lines=16) @@ | ||
| 4349 | * |
|
| 4350 | * @phpstan-param \Closure(T=,TKey=):bool $closure |
|
| 4351 | */ |
|
| 4352 | public function matchesAny(\Closure $closure): bool |
|
| 4353 | { |
|
| 4354 | if ($this->count() === 0) { |
|
| 4355 | return false; |
|
| 4356 | } |
|
| 4357 | ||
| 4358 | foreach ($this->getGenerator() as $key => $value) { |
|
| 4359 | $value = $closure($value, $key); |
|
| 4360 | ||
| 4361 | if ($value === true) { |
|
| 4362 | return true; |
|
| 4363 | } |
|
| 4364 | } |
|
| 4365 | ||
| 4366 | return false; |
|
| 4367 | } |
|
| 4368 | ||
| 4369 | /** |
|
| 4370 | * Get the max value from an array. |
|