Completed
Pull Request — master (#87)
by Vladimir
02:24
created

TwigTemplate::getParentTemplate()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 0
cts 6
cp 0
rs 9.9
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 6
1
<?php
2
3
/**
4
 * @copyright 2018 Vladimir Jimenez
5
 * @license   https://github.com/stakx-io/stakx/blob/master/LICENSE.md MIT
6
 */
7
8
namespace allejo\stakx\Templating\Twig;
9
10
use allejo\stakx\Templating\TemplateInterface;
11
12
class TwigTemplate implements TemplateInterface
13
{
14
    private $template;
15
16 12
    public function __construct(\Twig_Template $template)
17
    {
18 12
        $this->template = $template;
19 12
    }
20
21
    /**
22
     * {@inheritdoc}
23
     */
24 12
    public function getTemplateName()
25
    {
26 12
        return $this->template->getTemplateName();
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function getParentTemplate()
33
    {
34
        $parent = $this->template->getParent([]);
35
36
        if ($parent === false)
37
        {
38
            return false;
39
        }
40
41
        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...
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47 12
    public function render(array $context = [])
48
    {
49 12
        return $this->template->render($context);
50
    }
51
}
52