Conditions | 6 |
Paths | 3 |
Total Lines | 19 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
40 | public function locateConfigFile(string $path): string |
||
41 | { |
||
42 | if (is_file($path)) { |
||
43 | return $path; |
||
44 | } |
||
45 | |||
46 | $dirPath = realpath($path) ?: getcwd(); |
||
47 | assert(is_dir((string) $dirPath)); |
||
48 | |||
49 | do { |
||
50 | $maybePath = sprintf('%s/%s', $dirPath, $this->configName); |
||
51 | if (file_exists($maybePath) || file_exists($maybePath .= '.dist')) { |
||
52 | return $maybePath; |
||
53 | } |
||
54 | |||
55 | $dirPath = dirname($dirPath); // @phpstan-ignore-line |
||
56 | } while (dirname($dirPath) !== $dirPath); |
||
57 | |||
58 | throw new DataFileNotFoundException($path); |
||
59 | } |
||
61 |