Completed
Push — master ( 54ccda...232c7c )
by Changwan
04:16
created

Application::boot()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 7
nc 2
nop 0
dl 0
loc 11
ccs 7
cts 7
cp 1
crap 3
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\Bootstrap;
6
7
class Application extends Container
8
{
9
    const NAME = "Wandu";
10
    const VERSION = "4.0-dev";
11
12
    /** @var \Wandu\Foundation\Contracts\Bootstrap */
13
    protected $bootstrapper;
14
    
15 7
    public function __construct(Bootstrap $bootstrapper)
16
    {
17 7
        parent::__construct();
18 7
        $this->instance(Bootstrap::class, $this->bootstrapper = $bootstrapper);
19 7
    }
20
21
    /**
22
     * {@inheritdoc}
23
     */
24 7
    public function boot()
25
    {
26 7
        if (!$this->isBooted) {
27 7
            foreach ($this->bootstrapper->providers() as $provider) {
28 1
                $this->register($provider);
29
            }
30 7
            $this->bootstrapper->boot($this);
31 7
            parent::boot();
32
        }
33 7
        return $this;
34
    }
35
36
    /**
37
     * @return mixed
38
     */
39 2
    public function execute()
40
    {
41 2
        $this->boot();
42 2
        return $this->bootstrapper->execute($this);
43
    }
44
}
45