Total Complexity | 4 |
Total Lines | 36 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php declare(strict_types=1); |
||
7 | class RenderOpenApi |
||
8 | { |
||
9 | public const HTML = 'html'; |
||
10 | public const JSON = 'json'; |
||
11 | public const YAML = 'yaml'; |
||
12 | |||
13 | public const PHP_PATTERN = "*.php"; |
||
14 | |||
15 | /** |
||
16 | * @var array<string, OpenApiRendererInterface|null> |
||
17 | */ |
||
18 | private array $renderers; |
||
19 | |||
20 | public function __construct(OpenApiRendererInterface ...$renderers) |
||
21 | { |
||
22 | foreach ($renderers as $renderer) { |
||
23 | $this->renderers[$renderer->getFormat()] = $renderer; |
||
24 | } |
||
25 | } |
||
26 | |||
27 | public function getAvailableFormats(): array |
||
28 | { |
||
29 | return array_keys($this->renderers); |
||
30 | } |
||
31 | /** |
||
32 | * @throws \InvalidArgumentException If the area to dump is not valid |
||
33 | */ |
||
34 | public function render(string $format = RenderOpenApi::JSON, array $options = []): string |
||
43 | } |
||
44 | } |
||
45 |