Passed
Push — master ( 935f04...13f58e )
by Caen
03:43 queued 12s
created

BootsHydeKernel::boot()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 3
eloc 8
nc 2
nop 0
dl 0
loc 14
rs 10
c 2
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Hyde\Foundation\Concerns;
6
7
use Hyde\Foundation\FileCollection;
8
use Hyde\Foundation\PageCollection;
9
use Hyde\Foundation\RouteCollection;
10
11
/**
12
 * @internal Single-use trait for the HydeKernel class.
13
 *
14
 * @see \Hyde\Foundation\HydeKernel
15
 */
16
trait BootsHydeKernel
17
{
18
    private bool $readyToBoot = false;
19
    private bool $booting = false;
20
21
    public function boot(): void
22
    {
23
        if (! $this->readyToBoot || $this->booting) {
24
            return;
25
        }
26
27
        $this->booting = true;
28
29
        $this->files = FileCollection::boot($this);
0 ignored issues
show
Bug Best Practice introduced by
The property files does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
30
        $this->pages = PageCollection::boot($this);
0 ignored issues
show
Bug Best Practice introduced by
The property pages does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
31
        $this->routes = RouteCollection::boot($this);
0 ignored issues
show
Bug Best Practice introduced by
The property routes does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
32
33
        $this->booting = false;
34
        $this->booted = true;
0 ignored issues
show
Bug Best Practice introduced by
The property booted does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
35
    }
36
37
    /** @internal */
38
    public function readyToBoot(): void
39
    {
40
        // To give package developers ample time to register their services,
41
        // don't want to boot the kernel until all providers have been registered.
42
43
        $this->readyToBoot = true;
44
    }
45
}
46