Renderer   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 91.67%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 6
c 3
b 0
f 0
lcom 1
cbo 3
dl 0
loc 55
ccs 22
cts 24
cp 0.9167
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 2
A content() 0 9 1
A getData() 0 4 1
A setData() 0 6 1
A getTemplateFolder() 0 7 1
1
<?php
2
3
namespace Ndrx\Profiler\Renderer\Html;
4
5
use Ndrx\Profiler\Renderer\RendererInterface;
6
7
/**
8
 * Interface Renderer
9
 * @package Ndrx\Profiler\Renderer
10
 */
11
abstract class Renderer implements RendererInterface
12
{
13
    /**
14
     * @var array
15
     */
16
    protected $profile;
17
18
    /**
19
     * Renderer constructor.
20
     */
21 88
    public function __construct(array $profile = [])
22
    {
23 88
        $this->profile = $profile;
24
25
        /** @var \Twig_Loader_Filesystem $loader */
26 88
        $loader = Template::getInstance()->getEngine()->getLoader();
27 88
        $paths = $loader->getPaths();
28 88
        if (!in_array($this->getTemplateFolder(), $paths, true)) {
29
            $loader->addPath($this->getTemplateFolder());
30
        }
31 88
    }
32
33
    /**
34
     * @return string
35
     */
36 74
    public function content()
37
    {
38 74
        return Template::getInstance()->getEngine()->render($this->getTemplate(), array_merge($this->getData(), [
39
            'meta' => [
40 74
                'icon' => $this->getIcon(),
41 74
                'title' => $this->getTitle()
42 74
            ]
43 74
        ]));
44
    }
45
46 74
    public function getData()
47
    {
48 74
        return $this->profile;
49
    }
50
51 18
    public function setData(array $data)
52
    {
53 18
        $this->profile = $data;
54
55 18
        return $this;
56
    }
57
58 88
    public function getTemplateFolder()
59
    {
60 88
        return __DIR__ . DIRECTORY_SEPARATOR . '..'
61 88
        . DIRECTORY_SEPARATOR . '..'
62 88
        . DIRECTORY_SEPARATOR . '..'
63 88
        . DIRECTORY_SEPARATOR . 'views';
64
    }
65
}
66