TwigRenderer::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
namespace Sugarcrm\UpgradeSpec\Template;
4
5
use Twig_Environment;
6
use Twig_LoaderInterface;
7
8
class TwigRenderer implements RendererInterface
9
{
10
    /**
11
     * @var Twig_Environment
12
     */
13
    private $engine;
14
15
    /**
16
     * TwigRenderer constructor.
17
     *
18
     * @param Twig_LoaderInterface $loader
19
     * @param bool                 $debug
20
     */
21
    public function __construct(Twig_LoaderInterface $loader, $debug = false)
22
    {
23
        $this->engine = new Twig_Environment($loader, ['debug' => $debug]);
24
    }
25
26
    /**
27
     * @param $name
28
     * @param $arguments
29
     *
30
     * @return string
31
     */
32
    public function render($name, $arguments)
33
    {
34
        $templatePath = sprintf('%s.twig', $name);
35
36
        return $this->engine->load($templatePath)->render($arguments);
37
    }
38
}
39