Lines
100.00%
3 / 3
Methods
100.00%
3 / 3
Classes
100.00%
1 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| format | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| parse | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 3 | ||
| isRequested | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 2 | ||
| 17 | final class ShutdownTime | |
| 18 | { | |
| 19 | public static function format(DateTimeInterface $time): string | |
| 20 | { | |
| 21 | return $time->format('U.u'); | |
| 22 | } | |
| 23 | ||
| 24 | public static function parse(mixed $value): ?float | |
| 25 | { | |
| 26 | return is_string($value) && is_numeric($value) ? (float) $value : null; | |
| 27 | } | |
| 28 | ||
| 29 | /** | |
| 30 | * True when the shutdown was requested after the worker started and is not in the future. | |
| 31 | */ | |
| 32 | public static function isRequested(float $shutdownTime, DateTimeInterface $startTime, float $now): bool | |
| 33 | { | |
| 34 | return $shutdownTime <= $now && $shutdownTime > $startTime->format('U.u'); | |
| 35 | } | |
| 36 | } |