| Conditions | 4 |
| Paths | 4 |
| Total Lines | 16 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 7 |
| CRAP Score | 4.7691 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 28 | 1 | public function locate(array $searchableDirs, string $env = ''): string |
|
| 29 | { |
||
| 30 | 1 | foreach ($searchableDirs as $expectedDir) { |
|
| 31 | 1 | foreach(self::$possibleConfigFileNames as $possibleConfigFileName){ |
|
| 32 | 1 | $possibleConfigFileName = str_replace('{env}', $env, $possibleConfigFileName); |
|
| 33 | 1 | $expectedFilepath = $expectedDir . DIRECTORY_SEPARATOR . $possibleConfigFileName; |
|
| 34 | 1 | if(is_file($expectedFilepath)){ |
|
| 35 | 1 | return realpath($expectedDir) . DIRECTORY_SEPARATOR . $possibleConfigFileName; |
|
| 36 | } |
||
| 37 | } |
||
| 38 | } |
||
| 39 | |||
| 40 | throw new \RuntimeException( |
||
| 41 | sprintf( |
||
| 42 | 'Could not find config file (%s)', |
||
| 43 | implode(', ', self::$possibleConfigFileNames) |
||
| 44 | ) |
||
| 47 | } |