Total Complexity | 6 |
Total Lines | 34 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
15 | class DateTime extends ScalarType |
||
16 | { |
||
17 | // phpcs:disable SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingAnyTypeHint |
||
18 | public string|null $description = 'The `DateTime` scalar type represents datetime data.' |
||
19 | . 'The format is ISO-8601 e.g. 2004-02-12T15:19:21+00:00'; |
||
20 | |||
21 | public function parseLiteral(ASTNode $valueNode, array|null $variables = null): string |
||
31 | } |
||
32 | |||
33 | public function parseValue(mixed $value): PHPDateTime |
||
34 | { |
||
35 | if (! is_string($value)) { |
||
36 | throw new Error('Date is not a string: ' . $value); |
||
37 | } |
||
38 | |||
39 | return PHPDateTime::createFromFormat('Y-m-d\TH:i:sP', $value); |
||
40 | } |
||
41 | |||
42 | public function serialize(mixed $value): string|null |
||
49 | } |
||
50 | } |
||
51 |