Application   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 59
rs 10
c 0
b 0
f 0
wmc 8
lcom 1
cbo 2

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getConfigValueByKey() 0 7 2
A getApp() 0 7 2
A setApp() 0 8 2
A getConfig() 0 4 1
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