Conditions | 5 |
Paths | 3 |
Total Lines | 20 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 5 |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
44 | 26 | public function validate($value, $field = null, $allFields = null) |
|
45 | { |
||
46 | 26 | $parameters = $this->getParameter(); |
|
47 | 26 | $format = $parameters['format']; |
|
48 | |||
49 | 26 | if ( (is_object($value) and ! method_exists($value, '__toString')) or $this->getParameter() === null ) |
|
50 | { |
||
51 | 3 | return false; |
|
52 | } |
||
53 | |||
54 | 23 | if ( ! $format ) |
|
55 | { |
||
56 | 9 | return false; |
|
57 | } |
||
58 | |||
59 | 14 | $date = date_parse_from_format($format, (string) $value); |
|
60 | |||
61 | 14 | return ( $date['error_count'] + $date['warning_count'] === 0 ); |
|
62 | |||
63 | } |
||
64 | |||
87 |