1 | <?php |
||
21 | abstract class AbstractDateTimeComparator extends AbstractParametrizedValidator { |
||
22 | |||
23 | /** |
||
24 | * Holds the amount of parameters. |
||
25 | */ |
||
26 | protected $amountOfParameters = 1; |
||
27 | |||
28 | /** |
||
29 | * Holds the type of the validator. |
||
30 | */ |
||
31 | protected $type; |
||
32 | |||
33 | /** |
||
34 | * Holds whether to parse the parameters as \DateTimes so the child class |
||
35 | * can decide. |
||
36 | */ |
||
37 | protected $dateTimeParameters = true; |
||
38 | |||
39 | /** |
||
40 | * Compares date times. |
||
41 | * |
||
42 | * @param \DateTime $date |
||
43 | * the first date to compare |
||
44 | * @param \DateTime[] $datetimes |
||
45 | * the date times to compare to |
||
46 | * @param array $parameters |
||
47 | * the original validator parameters |
||
48 | * |
||
49 | * @return boolean |
||
50 | * true if the dates compare |
||
51 | */ |
||
52 | abstract protected function isValidComparison(\DateTime $date, array $datetimes, array $parameters); |
||
53 | |||
54 | /** |
||
55 | * Gets a date time format from the parameters if given or a default one. |
||
56 | * |
||
57 | * @param string[] $parameters |
||
58 | * the parameters |
||
59 | * |
||
60 | * @return string |
||
61 | * the date time format |
||
62 | */ |
||
63 | protected function getDateTimeFormat($parameters) { |
||
71 | |||
72 | /** |
||
73 | * Interprets the given parameters as date times and returns them. |
||
74 | * |
||
75 | * @param array $parameters |
||
76 | * the paramters |
||
77 | * @param string $format |
||
78 | * the date time format |
||
79 | * |
||
80 | * @return \DateTime[] |
||
81 | * the date times |
||
82 | */ |
||
83 | protected function getDateTimes(array $parameters, $format) { |
||
97 | |||
98 | /** |
||
99 | * {@inheritdoc} |
||
100 | */ |
||
101 | public function isValid($value, array $parameters) { |
||
121 | |||
122 | /** |
||
123 | * {@inheritdoc} |
||
124 | */ |
||
125 | public function getInvalidDetails() { |
||
128 | } |
||
129 |