| @@ 2683-2698 (lines=16) @@ | ||
| 2680 | * |
|
| 2681 | * @return bool |
|
| 2682 | */ |
|
| 2683 | public function matches(\Closure $closure): bool |
|
| 2684 | { |
|
| 2685 | if (\count($this->array, \COUNT_NORMAL) === 0) { |
|
| 2686 | return false; |
|
| 2687 | } |
|
| 2688 | ||
| 2689 | foreach ($this->getGenerator() as $key => $value) { |
|
| 2690 | $value = $closure($value, $key); |
|
| 2691 | ||
| 2692 | if ($value === false) { |
|
| 2693 | return false; |
|
| 2694 | } |
|
| 2695 | } |
|
| 2696 | ||
| 2697 | return true; |
|
| 2698 | } |
|
| 2699 | ||
| 2700 | /** |
|
| 2701 | * Check if any item in the current array matches a truth test. |
|
| @@ 2707-2722 (lines=16) @@ | ||
| 2704 | * |
|
| 2705 | * @return bool |
|
| 2706 | */ |
|
| 2707 | public function matchesAny(\Closure $closure): bool |
|
| 2708 | { |
|
| 2709 | if (\count($this->array, \COUNT_NORMAL) === 0) { |
|
| 2710 | return false; |
|
| 2711 | } |
|
| 2712 | ||
| 2713 | foreach ($this->getGenerator() as $key => $value) { |
|
| 2714 | $value = $closure($value, $key); |
|
| 2715 | ||
| 2716 | if ($value === true) { |
|
| 2717 | return true; |
|
| 2718 | } |
|
| 2719 | } |
|
| 2720 | ||
| 2721 | return false; |
|
| 2722 | } |
|
| 2723 | ||
| 2724 | /** |
|
| 2725 | * Get the max value from an array. |
|