Passed
Push — master ( 604c70...f4f5f5 )
by Caen
03:01 queued 12s
created

ManagesHydeKernel   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
eloc 11
c 1
b 0
f 0
dl 0
loc 39
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 7 1
A getInstance() 0 3 1
A setBasePath() 0 3 1
A setInstance() 0 3 1
A getBasePath() 0 3 1
A getSourceRoot() 0 3 1
A setSourceRoot() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Hyde\Foundation\Concerns;
6
7
use Hyde\Foundation\FileCollection;
8
use Hyde\Foundation\HydeKernel;
9
use Hyde\Foundation\PageCollection;
10
use Hyde\Foundation\RouteCollection;
11
12
/**
13
 * @internal Single-use trait for the HydeKernel class.
14
 *
15
 * @see \Hyde\Foundation\HydeKernel
16
 */
17
trait ManagesHydeKernel
18
{
19
    public function boot(): void
20
    {
21
        $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...
22
23
        $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...
24
        $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...
25
        $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...
26
    }
27
28
    public static function getInstance(): HydeKernel
29
    {
30
        return static::$instance;
31
    }
32
33
    public static function setInstance(HydeKernel $instance): void
34
    {
35
        static::$instance = $instance;
0 ignored issues
show
Bug Best Practice introduced by
The property instance does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
36
    }
37
38
    public function setBasePath(string $basePath): void
39
    {
40
        $this->basePath = rtrim($basePath, '/\\');
0 ignored issues
show
Bug Best Practice introduced by
The property basePath does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
41
    }
42
43
    public function getBasePath(): string
44
    {
45
        return $this->basePath;
46
    }
47
48
    public function setSourceRoot(string $sourceRoot): void
49
    {
50
        $this->sourceRoot = rtrim($sourceRoot, '/\\');
0 ignored issues
show
Bug Best Practice introduced by
The property sourceRoot does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
51
    }
52
53
    public function getSourceRoot(): string
54
    {
55
        return $this->sourceRoot;
56
    }
57
}
58