Application::getConfig()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
4
namespace Alnutile\Codereview;
5
6
/**
7
 * @codeCoverageIgnore
8
 */
9
class Application
10
{
11
12
    use CreateApp;
13
14
    /**
15
     * @var \Silly\Edition\Pimple\Application
16
     */
17
    protected $app;
18
19
    /**
20
     * Application constructor.
21
     * @param \Silly\Edition\Pimple\Application|null $app
22
     */
23
    public function __construct($app = null)
24
    {
25
        $this->app = $app;
26
    }
27
28
    public function getConfigValueByKey($key)
29
    {
30
        if (isset($this->getConfig()[$key])) {
31
            return $this->getConfig()[$key];
32
        }
33
        return null;
34
    }
35
36
    /**
37
     * @return \Silly\Edition\Pimple\Application
38
     */
39
    public function getApp()
40
    {
41
        if (!$this->app) {
42
            $this->setApp();
43
        }
44
        return $this->app;
45
    }
46
47
    /**
48
     * @param \Silly\Edition\Pimple\Application|null $app
49
     * @return $this
50
     */
51
    public function setApp($app = null)
52
    {
53
        if (!$app) {
54
            $app = $this->createApplication();
55
        }
56
        $this->app = $app;
57
        return $this;
58
    }
59
60
    /**
61
     * @return mixed
62
     */
63
    public function getConfig()
64
    {
65
        return $this->getApp()->getContainer()['config'];
66
    }
67
}
68