TwigRenderer   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

2 Methods

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