ComingSoon   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 10
dl 0
loc 44
c 0
b 0
f 0
rs 10
ccs 7
cts 7
cp 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 7 2
A __construct() 0 8 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace Norsys\SecurityBundle\Action;
5
6
use Symfony\Component\HttpFoundation\Response;
7
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
8
use Symfony\Component\Templating\EngineInterface;
9
10
/**
11
 * Class ComingSoon
12
 */
13
class ComingSoon
14
{
15
    /**
16
     * @var EngineInterface
17
     */
18
    private $templateEngine;
19
20
    /**
21
     * @var boolean
22
     */
23
    private $enabled;
24
25
    /**
26
     * @var string
27
     */
28
    private $template;
29
30
    /**
31
     * @param EngineInterface $templateEngine
32
     * @param boolean         $enabled
33
     * @param string          $template
34
     */
35
    public function __construct(
36
        EngineInterface $templateEngine,
37
        bool $enabled,
38
        string $template
39
    ) {
40 1
        $this->templateEngine = $templateEngine;
41 1
        $this->enabled        = $enabled;
42 1
        $this->template       = $template;
43 1
    }
44
45
    /**
46
     * @throws NotFoundHttpException
47
     *
48
     * @return Response
49
     */
50
    public function __invoke() : Response
51
    {
52 1
        if ($this->enabled === false) {
53 1
            throw new NotFoundHttpException();
54
        }
55
56 1
        return new Response($this->templateEngine->render($this->template));
57
    }
58
}
59