Conditions | 4 |
Paths | 4 |
Total Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
21 | public function validate($format, $value) |
||
22 | { |
||
23 | // full-date notation as defined by RFC 3339, section 5.6, for example, 2017-07-21 |
||
24 | if ($format === 'date' ) { |
||
25 | $match = preg_match('/^[\d]{4}-[\d]{2}-[\d]{2}$/', $value); |
||
26 | return $match !== false && $match !== 0; |
||
27 | } |
||
28 | |||
29 | // the date-time notation as defined by RFC 3339, section 5.6, for example, 2017-07-21T17:32:28Z |
||
30 | if ($format === 'date-time') { |
||
31 | return DateTime::createFromFormat(DateTime::ISO8601, $value) !== false; |
||
32 | } |
||
33 | |||
34 | return true; |
||
35 | } |
||
36 | } |
||
37 |