Test Failed
Push — master ( a3c6b7...453945 )
by Florian
01:58
created

TwigRenderer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Test Coverage

Coverage 75%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getTwig() 0 3 1
A __construct() 0 3 1
A render() 0 5 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace Phauthentic\Presentation\Renderer;
5
6
use Phauthentic\Presentation\View\ViewInterface;
7
use Twig\Environment;
8
9
/**
10
 * Twig Renderer
11
 */
12
class TwigRenderer extends AbstractBaseRenderer implements RendererInterface
13
{
14
    /**
15
     * Twig
16
     *
17
     * @var \Twig\Environment
18
     */
19
    protected $twig;
20
21
    /**
22
     * Extension
23
     *
24
     * @var string
25
     */
26
    protected $extension = 'html';
27
28
    /**
29
     * Constructor
30
     *
31
     * @param \Twig_Environment
32
     */
33 1
    public function __construct(Environment $twig)
34
    {
35 1
        $this->twig = $twig;
36 1
    }
37
38
    /**
39
     * Gets the Twig instance
40
     *
41
     * @return \Twig\Environment
42
     */
43
    public function getTwig(): Environment
44
    {
45
        return $this->twig;
46
    }
47
48
    /**
49
     * @inheritDoc
50
     */
51 1
    public function render(ViewInterface $render): string
52
    {
53 1
        $template = $this->twig->load($render->getTemplate() . '.' . $this->getTemplateExtension());
54
55 1
        return $template->render($render->getViewVars());
56
    }
57
}
58