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

TwigRenderer::getTwig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
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