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