| Total Complexity | 6 |
| Total Lines | 42 |
| Duplicated Lines | 0 % |
| Coverage | 84.62% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 14 | final class DateType extends ScalarType |
||
| 15 | { |
||
| 16 | public ?string $description = 'A date without time, nor timezone.'; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * Serializes an internal value to include in a response. |
||
| 20 | */ |
||
| 21 | 1 | public function serialize(mixed $value): mixed |
|
| 28 | } |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Parses an externally provided value (query variable) to use as an input. |
||
| 32 | */ |
||
| 33 | 8 | public function parseValue(mixed $value): ChronosDate |
|
| 34 | { |
||
| 35 | 8 | if (!is_string($value)) { |
|
| 36 | throw new Error('Cannot represent value as Chronos date: ' . Utils::printSafe($value)); |
||
| 37 | } |
||
| 38 | |||
| 39 | 8 | $date = ChronosDate::createFromFormat('Y-m-d+', $value); |
|
| 40 | |||
| 41 | 8 | return $date; |
|
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * Parses an externally provided literal value to use as an input (e.g. in Query AST). |
||
| 46 | */ |
||
| 47 | 5 | public function parseLiteral(Node $valueNode, ?array $variables = null): ChronosDate |
|
| 56 | } |
||
| 57 | } |
||
| 58 |