@@ 20-38 (lines=19) @@ | ||
17 | * @package Dutek\Predicate |
|
18 | * @author Dušan Vejin <[email protected]> |
|
19 | */ |
|
20 | class AnyPredicate extends AbstractQuantifierPredicate |
|
21 | { |
|
22 | /** |
|
23 | * Evaluates the predicate returning true if any predicate returns true. |
|
24 | * |
|
25 | * @param mixed $value The input value. |
|
26 | * @return bool true if any decorated predicate return true |
|
27 | */ |
|
28 | public function __invoke($value) : bool |
|
29 | { |
|
30 | foreach ($this->predicates as $predicate) { |
|
31 | if ($predicate($value)) { |
|
32 | return true; |
|
33 | } |
|
34 | } |
|
35 | ||
36 | return false; |
|
37 | } |
|
38 | } |
|
39 |
@@ 20-38 (lines=19) @@ | ||
17 | * @package Dutek\Predicate |
|
18 | * @author Dušan Vejin <[email protected]> |
|
19 | */ |
|
20 | class NonePredicate extends AbstractQuantifierPredicate |
|
21 | { |
|
22 | /** |
|
23 | * Evaluates the predicate returning false if any stored predicate returns false. |
|
24 | * |
|
25 | * @param mixed $value The input value. |
|
26 | * @return bool true if none of decorated predicates return true. |
|
27 | */ |
|
28 | public function __invoke($value) : bool |
|
29 | { |
|
30 | foreach ($this->predicates as $predicate) { |
|
31 | if ($predicate($value)) { |
|
32 | return false; |
|
33 | } |
|
34 | } |
|
35 | ||
36 | return true; |
|
37 | } |
|
38 | } |
|
39 |