Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
66.67% covered (warning)
66.67%
4 / 6
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
SchemaUsages
66.67% covered (warning)
66.67%
4 / 6
0.00% covered (danger)
0.00%
0 / 1
4.59
0.00% covered (danger)
0.00%
0 / 1
 toSchema
66.67% covered (warning)
66.67%
4 / 6
0.00% covered (danger)
0.00%
0 / 1
4.59
1<?php
2namespace Apie\SchemaGenerator\Enums;
3
4use Apie\SchemaGenerator\Builders\ComponentsBuilder;
5use cebe\openapi\spec\Reference;
6use cebe\openapi\spec\Schema;
7
8enum 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}