Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
12 / 12 |
|
100.00% |
12 / 12 |
CRAP | |
100.00% |
1 / 1 |
ManagesHydeKernel | |
100.00% |
12 / 12 |
|
100.00% |
12 / 12 |
12 | |
100.00% |
1 / 1 |
getInstance | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setInstance | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getBasePath | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setBasePath | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getSourceRoot | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setSourceRoot | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getOutputDirectory | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setOutputDirectory | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getMediaDirectory | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setMediaDirectory | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getMediaOutputDirectory | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
normalizeSourcePath | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | declare(strict_types=1); |
4 | |
5 | namespace Hyde\Foundation\Concerns; |
6 | |
7 | use Hyde\Foundation\HydeKernel; |
8 | |
9 | use function ltrim; |
10 | use function rtrim; |
11 | |
12 | /** |
13 | * @internal Single-use trait for the HydeKernel class. |
14 | * |
15 | * @see \Hyde\Foundation\HydeKernel |
16 | */ |
17 | trait ManagesHydeKernel |
18 | { |
19 | public static function getInstance(): HydeKernel |
20 | { |
21 | return static::$instance; |
22 | } |
23 | |
24 | public static function setInstance(HydeKernel $instance): void |
25 | { |
26 | static::$instance = $instance; |
27 | } |
28 | |
29 | public function getBasePath(): string |
30 | { |
31 | return $this->basePath; |
32 | } |
33 | |
34 | public function setBasePath(string $basePath): void |
35 | { |
36 | $this->basePath = rtrim($basePath, '/\\'); |
37 | } |
38 | |
39 | public function getSourceRoot(): string |
40 | { |
41 | return $this->sourceRoot; |
42 | } |
43 | |
44 | public function setSourceRoot(string $sourceRoot): void |
45 | { |
46 | $this->sourceRoot = $this->normalizeSourcePath($sourceRoot); |
47 | } |
48 | |
49 | public function getOutputDirectory(): string |
50 | { |
51 | return $this->outputDirectory; |
52 | } |
53 | |
54 | public function setOutputDirectory(string $outputDirectory): void |
55 | { |
56 | $this->outputDirectory = $this->normalizeSourcePath($outputDirectory); |
57 | } |
58 | |
59 | public function getMediaDirectory(): string |
60 | { |
61 | return $this->mediaDirectory; |
62 | } |
63 | |
64 | public function setMediaDirectory(string $mediaDirectory): void |
65 | { |
66 | $this->mediaDirectory = $this->normalizeSourcePath($mediaDirectory); |
67 | } |
68 | |
69 | public function getMediaOutputDirectory(): string |
70 | { |
71 | return ltrim($this->getMediaDirectory(), '_'); |
72 | } |
73 | |
74 | protected function normalizeSourcePath(string $outputDirectory): string |
75 | { |
76 | return $this->pathToRelative(rtrim($outputDirectory, '/\\')); |
77 | } |
78 | } |