| Total Complexity | 5 |
| Total Lines | 29 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 16 | class Date |
||
| 17 | { |
||
| 18 | /** |
||
| 19 | * Checks if a date is valid. |
||
| 20 | */ |
||
| 21 | public static function isValid(string $date, string $format = 'Y-m-d'): bool |
||
| 22 | { |
||
| 23 | $d = \DateTime::createFromFormat($format, $date); |
||
| 24 | |||
| 25 | return $d && $d->format($format) === $date; |
||
| 26 | } |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Date to DateTime. |
||
| 30 | * |
||
| 31 | * @param mixed $date Can be a DateTIme object, a timestamp or a string |
||
| 32 | */ |
||
| 33 | public static function toDatetime($date): \DateTime |
||
| 45 | } |
||
| 46 | } |
||
| 47 |