Application::getSaver()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace XHGui;
4
5
use Pimple\Container;
6
use Slim\Slim as App;
7
use XHGui\Saver\SaverInterface;
8
9
class Application extends Container
10
{
11
    /** @var bool */
12
    private $booted = false;
13
14
    public function __construct()
15
    {
16
        parent::__construct();
17
        $this->register(new ServiceProvider\ServiceProvider());
18
        $this->register(new ServiceProvider\ConfigProvider());
19
        $this->register(new ServiceProvider\PdoStorageProvider());
20
        $this->register(new ServiceProvider\MongoStorageProvider());
21
        $this->register(new ServiceProvider\SlimProvider());
22
    }
23
24
    public function run(): void
25
    {
26
        $this->boot()->getSlim()->run();
27
    }
28
29
    public function boot(): self
30
    {
31
        if (!$this->booted) {
32
            $this->register(new ServiceProvider\RouteProvider());
33
            $this->booted = true;
34
        }
35
36
        return $this;
37
    }
38
39
    public function getSlim(): App
40
    {
41
        return $this['app'];
42
    }
43
44
    public function getSaver(): SaverInterface
45
    {
46
        return $this['saver'];
47
    }
48
}
49