| @@ 2570-2585 (lines=16) @@ | ||
| 2567 | * |
|
| 2568 | * @return bool |
|
| 2569 | */ |
|
| 2570 | public function matches(\Closure $closure): bool |
|
| 2571 | { |
|
| 2572 | if (\count($this->getArray(), \COUNT_NORMAL) === 0) { |
|
| 2573 | return false; |
|
| 2574 | } |
|
| 2575 | ||
| 2576 | foreach ($this->getGenerator() as $key => $value) { |
|
| 2577 | $value = $closure($value, $key); |
|
| 2578 | ||
| 2579 | if ($value === false) { |
|
| 2580 | return false; |
|
| 2581 | } |
|
| 2582 | } |
|
| 2583 | ||
| 2584 | return true; |
|
| 2585 | } |
|
| 2586 | ||
| 2587 | /** |
|
| 2588 | * Check if any item in the current array matches a truth test. |
|
| @@ 2594-2609 (lines=16) @@ | ||
| 2591 | * |
|
| 2592 | * @return bool |
|
| 2593 | */ |
|
| 2594 | public function matchesAny(\Closure $closure): bool |
|
| 2595 | { |
|
| 2596 | if (\count($this->getArray(), \COUNT_NORMAL) === 0) { |
|
| 2597 | return false; |
|
| 2598 | } |
|
| 2599 | ||
| 2600 | foreach ($this->getGenerator() as $key => $value) { |
|
| 2601 | $value = $closure($value, $key); |
|
| 2602 | ||
| 2603 | if ($value === true) { |
|
| 2604 | return true; |
|
| 2605 | } |
|
| 2606 | } |
|
| 2607 | ||
| 2608 | return false; |
|
| 2609 | } |
|
| 2610 | ||
| 2611 | /** |
|
| 2612 | * Get the max value from an array. |
|