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

ConfigPanel   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 93
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 3
dl 0
loc 93
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 5 1
A getConfig() 0 7 2
A setConfig() 0 5 1
A getDebugger() 0 7 2
A setDebugger() 0 5 1
A getTab() 0 4 1
A getPanel() 0 4 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\Exception;
13
use WebinoDebug\Factory\DebuggerFactory;
14
use Zend\Config\Config;
15
use Zend\ServiceManager\ServiceManager;
16
17
/**
18
 * Class ConfigPanel
19
 */
20
class ConfigPanel extends AbstractPanel implements
21
    PanelInterface,
22
    PanelInitInterface
23
{
24
    /**
25
     * @var array|Config
26
     */
27
    private $config;
28
29
    /**
30
     * @var DebuggerInterface
31
     */
32
    private $debugger;
33
34
    /**
35
     * @var string
36
     */
37
    protected $title = 'Application config';
38
39
    /**
40
     * @var string
41
     */
42
    protected $content = '';
43
44
    /**
45
     * @param ServiceManager $services
46
     */
47
    public function init(ServiceManager $services)
48
    {
49
        $this->setConfig(array_merge(['core' => $services->get('ApplicationConfig')], $services->get('Config')));
50
        $this->setDebugger($services->get(DebuggerFactory::SERVICE));
0 ignored issues
show
Documentation introduced by
$services->get(\WebinoDe...buggerFactory::SERVICE) is of type object|array, but the function expects a object<WebinoDebug\Debugger\DebuggerInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
51
    }
52
53
    /**
54
     * @return array
55
     * @throws Exception\LogicException
56
     */
57
    protected function getConfig()
58
    {
59
        if (null === $this->config) {
60
            throw new Exception\LogicException('Expected `config`');
61
        }
62
        return $this->config;
63
    }
64
65
    /**
66
     * @param array $config
67
     * @return $this
68
     */
69
    public function setConfig(array $config)
70
    {
71
        $this->config = $config;
72
        return $this;
73
    }
74
75
    /**
76
     * @return DebuggerInterface
77
     * @throws Exception\LogicException
78
     */
79
    protected function getDebugger()
80
    {
81
        if (null === $this->debugger) {
82
            throw new Exception\LogicException('Expected `debugger`');
83
        }
84
        return $this->debugger;
85
    }
86
87
    /**
88
     * @param object|DebuggerInterface $debugger
89
     * @return $this
90
     */
91
    public function setDebugger(DebuggerInterface $debugger)
92
    {
93
        $this->debugger = $debugger;
94
        return $this;
95
    }
96
97
    /**
98
     * {@inheritdoc}
99
     */
100
    public function getTab()
101
    {
102
        return $this->createIcon('config', 'top: -3px;') . parent::getTab();
103
    }
104
105
    /**
106
     * {@inheritdoc}
107
     */
108
    public function getPanel()
109
    {
110
        return $this->renderTemplate('config.panel');
111
    }
112
}
113