Completed
Push — master ( e49f26...876a6f )
by Kévin
10s
created

SwaggerUiAction   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A __invoke() 0 7 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\Bridge\Symfony\Bundle\Action;
13
14
use Symfony\Component\HttpFoundation\Response;
15
16
/**
17
 * Displays the documentation in Swagger UI.
18
 *
19
 * @author Kévin Dunglas <[email protected]>
20
 */
21
class SwaggerUiAction
22
{
23
    private $twig;
24
    private $title;
25
    private $description;
26
27
    public function __construct(\Twig_Environment $twig, string $title, string $description)
28
    {
29
        $this->twig = $twig;
30
        $this->title = $title;
31
        $this->description = $description;
32
    }
33
34
    public function __invoke()
35
    {
36
        return new Response($this->twig->render(
37
            'ApiPlatformBundle:SwaggerUi:index.html.twig',
38
            ['title' => $this->title, 'description' => $this->description]
39
        ));
40
    }
41
}
42