| Conditions | 4 |
| Paths | 4 |
| Total Lines | 18 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | <?php |
||
| 33 | 22 | public static function isValidDateString($str) |
|
| 34 | { |
||
| 35 | 22 | if (!is_string($str)) { |
|
| 36 | 3 | return false; |
|
| 37 | } |
||
| 38 | |||
| 39 | 19 | if (preg_match('/^(\d{4})-(\d{2})-(\d{2})T((\d{2}):(\d{2}):(\d{2})(\.\d{3}(Z)?)?([+-]\d{2}:\d{2})?)$/', $str)) { |
|
| 40 | 10 | return true; |
|
| 41 | } |
||
| 42 | |||
| 43 | 9 | $stamp = strtotime($str); |
|
| 44 | |||
| 45 | 9 | if (!is_numeric($stamp)) { |
|
| 46 | 4 | return false; |
|
| 47 | } |
||
| 48 | |||
| 49 | 5 | return checkdate(date('m', $stamp), date('d', $stamp), date('Y', $stamp)); |
|
| 50 | } |
||
| 51 | } |
||
| 52 |