Total Complexity | 6 |
Total Lines | 34 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
15 | class TimeImmutable extends ScalarType |
||
16 | { |
||
17 | // phpcs:disable SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingAnyTypeHint |
||
18 | public string|null $description = 'The `Time` scalar type represents time data.' |
||
19 | . 'The format is e.g. 24 hour:minutes:seconds'; |
||
20 | |||
21 | public function parseLiteral(ASTNode $valueNode, array|null $variables = null): string |
||
31 | } |
||
32 | |||
33 | public function parseValue(mixed $value): PHPDateTime|false |
||
34 | { |
||
35 | if (! is_string($value)) { |
||
36 | throw new Error('Time is not a string: ' . $value); |
||
37 | } |
||
38 | |||
39 | return PHPDateTime::createFromFormat('H:i:s.u', $value); |
||
40 | } |
||
41 | |||
42 | public function serialize(mixed $value): string|null |
||
49 | } |
||
50 | } |
||
51 |