AbstractPanel   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 54
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getTab() 0 7 2
A createIcon() 0 8 3
A renderTemplate() 0 7 1
1
<?php
2
/**
3
 * Webino (http://webino.sk/)
4
 *
5
 * @link        https://github.com/webino/WebinoDebug/ for the canonical source repository
6
 * @copyright   Copyright (c) 2014-2018 Webino, s. r. o. (http://webino.sk/)
7
 * @license     BSD-3-Clause
8
 */
9
10
namespace WebinoDebug\Debugger;
11
12
use Zend\Escaper\EscaperAwareTrait;
13
14
/**
15
 * Class AbstractPanel
16
 */
17
abstract class AbstractPanel
18
{
19
    use EscaperAwareTrait;
20
21
    /**
22
     * @var string
23
     */
24
    protected $label = '';
25
26
    /**
27
     * @var string
28
     */
29
    protected $title = '';
30
31
    /**
32
     * @var string
33
     */
34
    protected $dir = __DIR__;
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    public function getTab()
40
    {
41
        if (!$this->label) {
42
            return '';
43
        }
44
        return sprintf('<span title="%s" class="tracy-label">%s</span>', $this->title, $this->label);
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50
    public function createIcon($name, $style = '')
51
    {
52
        $data   = file_get_contents($this->dir . '/../../../data/assets/Debugger/' . $name . '.png');
53
        $base64 = 'data:image/png;base64,' . base64_encode($data);
54
        $style  = $style ? 'style="' . $style . '"' : '';
55
        $title  = $this->title ? 'title="' . $this->title . '"' : '';
56
        return sprintf('<img src="%s" %s %s/>', $base64, $style, $title);
57
    }
58
59
    /**
60
     * @param $name
61
     * @return string
62
     */
63
    public function renderTemplate($name)
64
    {
65
        ob_start();
66
        /** @noinspection PhpIncludeInspection */
67
        require $this->dir . '/../../../data/assets/Debugger/' . $name . '.phtml';
68
        return ob_get_clean();
69
    }
70
}
71