TwitalEngine::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
ccs 4
cts 4
cp 1
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
namespace Goetas\TwitalBundle\Engine;
4
5
use Symfony\Bridge\Twig\TwigEngine;
6
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
7
use Symfony\Component\HttpFoundation\Response;
8
use Symfony\Component\Templating\TemplateNameParserInterface;
9
10
/**
11
 *
12
 * @author Asmir Mustafic <[email protected]>
13
 * @author Martin Hasoň <[email protected]>
14
 *
15
 */
16
class TwitalEngine implements EngineInterface
17
{
18
    private $twigEngine;
19
    private $parser;
20
21 4
    public function __construct(TwigEngine $twigEngine, TemplateNameParserInterface $parser)
22
    {
23 4
        $this->twigEngine = $twigEngine;
24 4
        $this->parser = $parser;
25 4
    }
26
27 1
    public function render($name, array $parameters = array())
28
    {
29 1
        return $this->twigEngine->render($name, $parameters);
30
    }
31
32 2
    public function exists($name)
33
    {
34 2
        return $this->twigEngine->exists($name);
35
    }
36
37 1
    public function supports($name)
38
    {
39 1
        $template = $this->parser->parse($name);
40
41 1
        return 'twital' === $template->get('engine');
42
    }
43
44
    public function renderResponse($view, array $parameters = array(), Response $response = null)
45
    {
46
        return $this->twigEngine->renderResponse($view, $parameters, $response);
47
    }
48
}
49