Completed
Push — master ( 07981c...e259b1 )
by wen
25:43
created

Component::bootIfNotBooted()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 6
nc 2
nop 0
1
<?php
2
3
4
namespace Sco\Admin\Component;
5
6
7
use Sco\Admin\Component\Concerns\HasEvents;
8
use Sco\Admin\Contracts\ComponentInterface;
9
10
abstract class Component implements ComponentInterface
11
{
12
    use HasEvents;
13
14
    protected static $dispatcher;
15
16
    protected static $booted = [];
17
18
    public function __construct()
19
    {
20
        $this->bootIfNotBooted();
21
22
    }
23
24
    protected function bootIfNotBooted()
25
    {
26
        if (!isset(static::$booted[static::class])) {
27
            static::$booted[static::class] = true;
28
29
            $this->fireEvent('booting', false);
30
31
            static::boot();
32
33
            $this->fireEvent('booted', false);
34
        }
35
    }
36
37
    protected static function boot()
38
    {
39
    }
40
}
41