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

TwigTemplate   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 58.33%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 39
ccs 7
cts 12
cp 0.5833
rs 10
c 0
b 0
f 0

4 Methods

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