Completed
Push — master ( 3a56df...caf2ba )
by Vladimir
02:43
created

StakxTwigTextProfiler::getMappedTemplateName()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 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\Twig;
9
10
use Twig_Profiler_Dumper_Text;
11
use Twig_Profiler_Profile;
12
13
class StakxTwigTextProfiler extends Twig_Profiler_Dumper_Text
14
{
15
    private $templateMappings;
16
17
    public function setTemplateMappings($templateMappings)
18
    {
19
        $this->templateMappings = $templateMappings;
20
    }
21
22
    protected function formatTemplate(Twig_Profiler_Profile $profile, $prefix)
23
    {
24
        return sprintf('%sā”” %s', $prefix, $this->getMappedTemplateName($profile));
25
    }
26
27
    protected function formatNonTemplate(Twig_Profiler_Profile $profile, $prefix)
28
    {
29
        return sprintf('%sā”” %s::%s(%s)', $prefix, $this->getMappedTemplateName($profile), $profile->getType(), $profile->getName());
30
    }
31
32
    private function getMappedTemplateName(Twig_Profiler_Profile $profile)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
33
    {
34
        $name = $profile->getTemplate();
35
36
        return isset($this->templateMappings[$name]) ? $this->templateMappings[$name] : $profile->getTemplate();
37
    }
38
}