Conditions | 4 |
Paths | 3 |
Total Lines | 12 |
Code Lines | 6 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
16 | public function validate($value): ?string |
||
17 | { |
||
18 | if (!is_string($value)) { |
||
19 | return "This value must be a string."; |
||
20 | } |
||
21 | |||
22 | $dateTime = \DateTime::createFromFormat($this->format, $value); |
||
23 | if (!$dateTime || $dateTime->format($this->format) !== $value) { |
||
|
|||
24 | return "This value must be a valid date in '{$this->format}' format."; |
||
25 | } |
||
26 | |||
27 | return null; |
||
28 | } |
||
29 | } |