Conditions | 6 |
Paths | 3 |
Total Lines | 20 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 6.027 |
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_null($value) and is_object($value) and ! method_exists($value, '__toString')) or $this->getParameter() === null ) |
|
50 | 26 | { |
|
51 | return false; |
||
52 | } |
||
53 | |||
54 | 26 | if ( ! $format ) |
|
55 | 26 | { |
|
56 | 10 | return false; |
|
57 | } |
||
58 | |||
59 | 16 | $date = date_parse_from_format($format, (string) $value); |
|
60 | |||
61 | 14 | return ( $date['error_count'] + $date['warning_count'] === 0 ); |
|
62 | |||
63 | } |
||
64 | |||
87 |