Completed
Push — master ( 39c1d7...699dc6 )
by Changwan
06:44
created

Application::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 1
dl 0
loc 7
ccs 6
cts 6
cp 1
crap 1
rs 9.4285
c 0
b 0
f 0
1
<?php
2
namespace Wandu\Foundation;
3
4
use Wandu\DI\Container;
5
use Wandu\Foundation\Contracts\KernelInterface;
6
7
class Application extends Container
8
{
9
    const NAME = "Wandu";
10
    const VERSION = "3.1-dev";
11
12
    /** @var \Wandu\Foundation\Contracts\KernelInterface */
13
    protected $kernel;
14
15
    /**
16
     * @param \Wandu\Foundation\Contracts\KernelInterface $kernel
17
     */
18 4
    public function __construct(KernelInterface $kernel)
19
    {
20 4
        parent::__construct();
21 4
        $this->instance(KernelInterface::class, $this->kernel = $kernel);
22 4
        $this->alias('kernel', KernelInterface::class);
23 4
        $this->setAsGlobal();
24 4
    }
25
26
    /**
27
     * {@inheritdoc}
28
     */
29 4
    public function boot()
30
    {
31 4
        if (!$this->isBooted) {
32 4
            $this->kernel->boot($this);
33 4
            parent::boot();
34
        }
35 4
        return $this;
36
    }
37
38
    /**
39
     * @return mixed
40
     */
41
    public function execute()
42
    {
43
        $this->boot();
44
        return $this->kernel->execute($this);
45
    }
46
}
47