1 | <?php |
||
17 | abstract class AbstractComparator extends AbstractParametrizedValidator { |
||
18 | |||
19 | /** |
||
20 | * Holds the amount of parameters. |
||
21 | */ |
||
22 | protected $amountOfParameters = 1; |
||
23 | |||
24 | /** |
||
25 | * Holds the type of the validator. |
||
26 | */ |
||
27 | protected $type; |
||
28 | |||
29 | /** |
||
30 | * Performs the comparison. |
||
31 | * |
||
32 | * @param mixed $value |
||
33 | * the first value to compare |
||
34 | * @param mixed $parameters |
||
35 | * the values to compare |
||
36 | * |
||
37 | * @return boolean |
||
38 | * true if value compares to the parameters |
||
39 | */ |
||
40 | abstract protected function isValidComparison($value, $parameters); |
||
41 | |||
42 | /** |
||
43 | * Checks whether all given parameters are numeric. |
||
44 | * |
||
45 | * @return boolean |
||
46 | * true if all values are numeric |
||
47 | */ |
||
48 | protected function isAllNumeric() { |
||
49 | foreach (func_get_args() as $value) { |
||
50 | if (!is_numeric($value)) { |
||
51 | return false; |
||
52 | } |
||
53 | } |
||
54 | return true; |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * {@inheritdoc} |
||
59 | */ |
||
60 | public function isValid($value, array $parameters) { |
||
67 | |||
68 | /** |
||
69 | * {@inheritdoc} |
||
70 | */ |
||
71 | public function getInvalidDetails() { |
||
74 | } |
||
75 |