Completed
Push — develop ( 179711...c18b9f )
by Peter
01:26
created

ConfigPanel::setConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
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\Exception;
13
use WebinoDebug\Factory\DebuggerFactory;
14
use WebinoDebug\Service\DebuggerAwareInterface;
15
use WebinoDebug\Service\DebuggerAwareTrait;
16
use Zend\Config\Config;
17
use Zend\ServiceManager\ServiceManager;
18
19
/**
20
 * Class ConfigPanel
21
 */
22
class ConfigPanel extends AbstractPanel implements
23
    PanelInterface,
24
    PanelInitInterface,
25
    DebuggerAwareInterface
26
{
27
    use DebuggerAwareTrait;
28
29
    /**
30
     * @var array|Config
31
     */
32
    private $config;
33
34
    /**
35
     * @var string
36
     */
37
    protected $title = 'Application config';
38
39
    /**
40
     * @param ServiceManager $services
41
     */
42
    public function init(ServiceManager $services)
43
    {
44
        $this->config = array_merge(['core' => $services->get('ApplicationConfig')], $services->get('Config'));
45
        $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...
46
    }
47
48
    /**
49
     * @return array
50
     * @throws Exception\LogicException
51
     */
52
    protected function getConfig()
53
    {
54
        if (null === $this->config) {
55
            throw new Exception\LogicException('Expected `config`');
56
        }
57
        return $this->config;
58
    }
59
60
    /**
61
     * {@inheritdoc}
62
     */
63
    public function getTab()
64
    {
65
        return $this->createIcon('config', 'top: -3px;');
66
    }
67
68
    /**
69
     * {@inheritdoc}
70
     */
71
    public function getPanel()
72
    {
73
        return $this->renderTemplate('config.panel');
74
    }
75
}
76