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

DocumentationAction   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 23
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __invoke() 0 6 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\Request;
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
     * @param Request $request
35
     *
36
     * @return array
37
     */
38
    public function __invoke(Request $request)
39
    {
40
        $request->attributes->set('_api_format', 'jsonld');
41
42
        return $this->apiDocumentationBuilder->getApiDocumentation();
43
    }
44
}
45