Total Complexity | 4 |
Total Lines | 38 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php declare(strict_types=1); |
||
7 | class Helper |
||
8 | { |
||
9 | private static $projectRootDirectory; |
||
10 | |||
11 | /** |
||
12 | * Get the absolute path to the root of the current project |
||
13 | * |
||
14 | * It does this by working from the Composer autoloader which we know will be in a certain place in `vendor` |
||
15 | * |
||
16 | * @return string |
||
17 | * @throws \Exception |
||
18 | */ |
||
19 | 2 | public static function getProjectRootDirectory(): string |
|
20 | { |
||
21 | 2 | if (null === self::$projectRootDirectory) { |
|
22 | 1 | $reflection = new \ReflectionClass(ClassLoader::class); |
|
23 | 1 | self::$projectRootDirectory = \dirname($reflection->getFileName(), 3); |
|
24 | } |
||
25 | |||
26 | 2 | return self::$projectRootDirectory; |
|
27 | } |
||
28 | |||
29 | /** |
||
30 | * @param string|null $path |
||
31 | * |
||
32 | * @return array |
||
33 | * @throws \Exception |
||
34 | * @SuppressWarnings(PHPMD.StaticAccess) |
||
35 | */ |
||
36 | 2 | public static function getComposerJsonDecoded(string $path = null): array |
|
45 | } |
||
46 | } |
||
47 |