Completed
Push — master ( c5da41...e1d486 )
by Pieter
22s queued 14s
created

DocsYamlController::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
namespace W2w\Lib\Apie\Controllers;
4
5
use W2w\Lib\Apie\OpenApiSchema\OpenApiSpecGenerator;
6
use Zend\Diactoros\Response\TextResponse;
7
8
/**
9
 * Returns the OpenAPI specs as YAML.
10
 */
11
class DocsYamlController
12
{
13
    /**
14
     * @var OpenApiSpecGenerator
15
     */
16
    private $openApiSpecGenerator;
17
18
    /**
19
     * @param OpenApiSpecGenerator $openApiSpecGenerator
20
     */
21
    public function __construct(OpenApiSpecGenerator $openApiSpecGenerator)
22
    {
23
        $this->openApiSpecGenerator = $openApiSpecGenerator;
24
    }
25
26
    public function __invoke()
27
    {
28
        return new TextResponse(
29
            $this->openApiSpecGenerator->getOpenApiSpec()->toYaml(),
30
            200,
31
            [
32
                'Content-Type' => 'application/vnd.oai.openapi+yaml',
33
            ]
34
        );
35
    }
36
}
37