Completed
Push — develop ( e297ce...b5d464 )
by Peter
02:16
created

AbstractPanel::getTab()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
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
        return '<img src="' . $base64 . '" style="' . $style . '" title="'. $this->title .'"/>';
55
    }
56
57
    /**
58
     * @param $name
59
     * @return string
60
     */
61
    public function renderTemplate($name)
62
    {
63
        ob_start();
64
        /** @noinspection PhpIncludeInspection */
65
        require $this->dir . '/../../../data/assets/Debugger/' . $name . '.phtml';
66
        return ob_get_clean();
67
    }
68
}
69