Total Complexity | 5 |
Total Lines | 42 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
5 | trait Bootable |
||
6 | { |
||
7 | /** @var bool */ |
||
8 | protected $booted = false; |
||
9 | |||
10 | /** |
||
11 | * Safely boot if wasn't booted before |
||
12 | * |
||
13 | * @return void |
||
14 | */ |
||
15 | public function bootIfNotBooted() : void |
||
16 | { |
||
17 | if ($this->isBooted()) { |
||
18 | return; |
||
19 | } |
||
20 | |||
21 | $this->boot(); |
||
22 | $this->booted(); |
||
23 | } |
||
24 | |||
25 | /** |
||
26 | * Runs after "boot" |
||
27 | * |
||
28 | * @return void |
||
29 | */ |
||
30 | protected function booted() : void |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * Determine if already booted |
||
37 | * |
||
38 | * @return bool |
||
39 | */ |
||
40 | public function isBooted() |
||
43 | } |
||
44 | |||
45 | protected function boot() : void |
||
47 | } |
||
48 | } |