Total Complexity | 4 |
Total Lines | 34 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
15 | final class UploadType extends ScalarType |
||
16 | { |
||
17 | public string $name = 'Upload'; |
||
18 | |||
19 | public ?string $description |
||
20 | = 'The `Upload` special type represents a file to be uploaded in the same HTTP request as specified by |
||
21 | [graphql-multipart-request-spec](https://github.com/jaydenseric/graphql-multipart-request-spec).'; |
||
22 | |||
23 | /** |
||
24 | * Serializes an internal value to include in a response. |
||
25 | */ |
||
26 | 1 | public function serialize(mixed $value): never |
|
29 | } |
||
30 | |||
31 | /** |
||
32 | * Parses an externally provided value (query variable) to use as an input. |
||
33 | */ |
||
34 | 3 | public function parseValue(mixed $value): UploadedFileInterface |
|
35 | { |
||
36 | 3 | if (!$value instanceof UploadedFileInterface) { |
|
37 | 1 | throw new UnexpectedValueException('Could not get uploaded file, be sure to conform to GraphQL multipart request specification. Instead got: ' . Utils::printSafe($value)); |
|
38 | } |
||
39 | |||
40 | 2 | return $value; |
|
41 | } |
||
42 | |||
43 | /** |
||
44 | * Parses an externally provided literal value (hardcoded in GraphQL query) to use as an input. |
||
45 | */ |
||
46 | 1 | public function parseLiteral(Node $valueNode, ?array $variables = null): mixed |
|
49 | } |
||
50 | } |
||
51 |