Completed
Push — master ( a6c8f9...b97be3 )
by Vladimir
03:52 queued 19s
created

TwigTemplate::getTemplateName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
/**
4
 * @copyright 2017 Vladimir Jimenez
5
 * @license   https://github.com/allejo/stakx/blob/master/LICENSE.md MIT
6
 */
7
8
namespace allejo\stakx\Templating;
9
10
class TwigTemplate implements TemplateInterface
11
{
12
    private $template;
13
14 14
    public function __construct(\Twig_Template $template)
15
    {
16 14
        $this->template = $template;
17 14
    }
18
19
    /**
20
     * {@inheritdoc}
21
     */
22 14
    public function getTemplateName()
23
    {
24 14
        return $this->template->getTemplateName();
25
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function getParentTemplate()
31
    {
32
        $parent = $this->template->getParent([]);
33
34
        if ($parent === false) {
35
            return false;
36
        }
37
38
        return (new TwigTemplate($parent));
0 ignored issues
show
Compatibility introduced by
$parent of type object<Twig_TemplateInterface> is not a sub-type of object<Twig_Template>. It seems like you assume a concrete implementation of the interface Twig_TemplateInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
39
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44 14
    public function render(array $context = [])
45
    {
46 14
        return $this->template->render($context);
47
    }
48
}
49