TwigRenderer   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A render() 0 6 1
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