| Total Complexity | 8 |
| Total Lines | 47 |
| Duplicated Lines | 0 % |
| Coverage | 88.24% |
| Changes | 0 | ||
| 1 | <?php |
||
| 22 | class Date |
||
| 23 | { |
||
| 24 | /** |
||
| 25 | * Checks if a date is valid. |
||
| 26 | */ |
||
| 27 | 1 | public static function isValid(string $date, string $format = 'Y-m-d'): bool |
|
| 28 | { |
||
| 29 | 1 | $d = \DateTime::createFromFormat($format, $date); |
|
| 30 | |||
| 31 | 1 | return $d && $d->format($format) === $date; |
|
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Date to DateTime. |
||
| 36 | * |
||
| 37 | * @param mixed $date |
||
| 38 | */ |
||
| 39 | 1 | public static function toDatetime($date): \DateTime |
|
| 58 | } |
||
| 59 | |||
| 60 | /** |
||
| 61 | * Duration in seconds to ISO 8601. |
||
| 62 | */ |
||
| 63 | 1 | public static function durationToIso8601(float $duration): string |
|
| 71 |