Total Complexity | 5 |
Total Lines | 28 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
29 | final class SymfonyUidPhpTypeSchemaResolver implements OpenApiPhpTypeSchemaResolverInterface |
||
30 | { |
||
31 | 3 | public function supportsPhpType(Type $phpType, Reflector $phpTypeHolder): bool |
|
32 | { |
||
33 | 3 | return is_subclass_of($phpType->name, AbstractUid::class); |
|
34 | } |
||
35 | |||
36 | /** |
||
37 | * @inheritDoc |
||
38 | */ |
||
39 | 3 | public function resolvePhpTypeSchema(Type $phpType, Reflector $phpTypeHolder): array |
|
40 | { |
||
41 | 3 | $this->supportsPhpType($phpType, $phpTypeHolder) or throw new UnsupportedPhpTypeException(); |
|
42 | |||
43 | 3 | $phpTypeSchema = [ |
|
44 | 3 | 'type' => Type::OAS_TYPE_NAME_STRING, |
|
45 | 3 | ]; |
|
46 | |||
47 | 3 | if (is_a($phpType->name, Uuid::class, true)) { |
|
48 | 3 | $phpTypeSchema['format'] = 'uuid'; |
|
49 | } |
||
50 | |||
51 | 3 | return $phpTypeSchema; |
|
52 | } |
||
53 | |||
54 | 3 | public function getWeight(): int |
|
57 | } |
||
58 | } |
||
59 |