Completed
Pull Request — master (#591)
by Amrouche
03:11
created

DocumentationAction   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 0
cbo 2
dl 0
loc 17
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __invoke() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the API Platform project.
5
 *
6
 * (c) Kévin Dunglas <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace ApiPlatform\Core\Documentation\Action;
13
14
use ApiPlatform\Core\Documentation\ApiDocumentationBuilderInterface;
15
use Symfony\Component\HttpFoundation\JsonResponse;
16
17
/**
18
 * Generates the Hydra API documentation.
19
 *
20
 * @author Kévin Dunglas <[email protected]>
21
 */
22
final class DocumentationAction
23
{
24
    private $apiDocumentationBuilder;
25
26
    public function __construct(ApiDocumentationBuilderInterface $apiDocumentationBuilder)
27
    {
28
        $this->apiDocumentationBuilder = $apiDocumentationBuilder;
29
    }
30
31
    /**
32
     * Gets API doc.
33
     */
34
    public function __invoke() : JsonResponse
35
    {
36
        return new JsonResponse($this->apiDocumentationBuilder->getApiDocumentation(), JsonResponse::HTTP_OK, ['Content-Type' => 'application/ld+json']);
37
    }
38
}
39