Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
66.67% |
4 / 6 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| SchemaUsages | |
66.67% |
4 / 6 |
|
0.00% |
0 / 1 |
4.59 | |
0.00% |
0 / 1 |
| toSchema | |
66.67% |
4 / 6 |
|
0.00% |
0 / 1 |
4.59 | |||
| 1 | <?php |
| 2 | namespace Apie\SchemaGenerator\Enums; |
| 3 | |
| 4 | use Apie\SchemaGenerator\Builders\ComponentsBuilder; |
| 5 | use cebe\openapi\spec\Reference; |
| 6 | use cebe\openapi\spec\Schema; |
| 7 | |
| 8 | enum SchemaUsages: string |
| 9 | { |
| 10 | case CREATE = 'post'; |
| 11 | case MODIFY = 'patch'; |
| 12 | case GET = 'get'; |
| 13 | |
| 14 | public function toSchema(ComponentsBuilder $componentsBuilder, string $className, bool $nullable = false): Schema|Reference |
| 15 | { |
| 16 | $method = match($this) { |
| 17 | self::CREATE => 'addCreationSchemaFor', |
| 18 | self::MODIFY => 'addModificationSchemaFor', |
| 19 | default => 'addDisplaySchemaFor' |
| 20 | }; |
| 21 | return $componentsBuilder->$method($className, nullable: $nullable); |
| 22 | } |
| 23 | } |