InfoPanel::init()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 18
rs 9.6666
cc 2
nc 2
nop 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 WebinoDebug\Factory\DebuggerFactory;
13
use WebinoDebug\Options\ModuleOptions;
14
use Zend\ServiceManager\ServiceManager;
15
16
/**
17
 * Class InfoPanel
18
 */
19
class InfoPanel extends AbstractPanel implements
20
    PanelInterface,
21
    PanelInitInterface
22
{
23
    /**
24
     * @var string|null
25
     */
26
    protected $barTitle;
27
28
    /**
29
     * @var string
30
     */
31
    protected $root;
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function init(ServiceManager $services)
37
    {
38
        /** @var \WebinoDebug\Options\ModuleOptions $options */
39
        $options = $services->get(ModuleOptions::class);
40
        /** @var \WebinoDebug\Service\Debugger $debugger */
41
        $debugger = $services->get(DebuggerFactory::SERVICE);
42
43
        // set bar title
44
        $this->barTitle = $options->getBarTitle();
45
46
        // set bar info
47
        foreach ($options->getBarInfo() as $name => $value) {
48
            $debugger->setBarInfo($name, $value);
49
        }
50
51
        // remember system root
52
        $this->root = realpath('.');
53
    }
54
55
    /**
56
     * {@inheritdoc}
57
     */
58
    public function getTab()
59
    {
60
        chdir($this->root);
61
        return '<span id="webino-debug-bar-meta" data-bar-title="' . $this->barTitle . '"></span>';
62
    }
63
64
    /**
65
     * {@inheritdoc}
66
     */
67
    public function getPanel()
68
    {
69
        return ' ';
70
    }
71
}
72