TwigRenderer::render()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
/**
3
 * @file
4
 * Contains \NotAFramework\App\Render\TwigRenderer.
5
 */
6
7
namespace NotAFramework\App\Render;
8
9
use Twig_LoaderInterface;
10
use Twig_Environment;
11
12
class TwigRenderer implements RendererInterface
13
{
14
    /**
15
     * The twig environment loader object.
16
     *
17
     * @var Twig_LoaderInterface
18
     */
19
    private $loader;
20
21
    /**
22
     * The twig environment object.
23
     *
24
     * @var Twig_Environment
25
     */
26
    private $twig;
27
28
    /**
29
     * Create a new TwigRenderer instance.
30
     */
31
    public function __construct(Twig_LoaderInterface $loader)
32
    {
33
        $this->loader = $loader;
34
        $this->twig = new Twig_Environment($loader);
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function render($template, $data = [])
41
    {
42
        // Render the template with the extension. We'll always use the same
43
        // file extension so theres no need to keep repeating it.
44
        return $this->twig->render("{$template}.html.twig", $data);
45
    }
46
}
47