Conditions | 5 |
Paths | 7 |
Total Lines | 26 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
17 | public function find($sourceDir) |
||
18 | { |
||
19 | $sourceDir = realpath($sourceDir); |
||
20 | |||
21 | if ($sourceDir === false) { |
||
22 | throw new RuntimeException('Не удалось получить канонизированный абсолютный путь к директории поиска'); |
||
23 | } |
||
24 | |||
25 | while (!file_exists($sourceDir . DIRECTORY_SEPARATOR . self::COMPOSER_JSON_FILENAME)) { |
||
26 | $parentDir = dirname($sourceDir); |
||
27 | |||
28 | if ($parentDir === $sourceDir) { |
||
29 | break; |
||
30 | } |
||
31 | |||
32 | $sourceDir = $parentDir; |
||
33 | } |
||
34 | |||
35 | $filePath = $sourceDir . DIRECTORY_SEPARATOR . self::COMPOSER_JSON_FILENAME; |
||
36 | |||
37 | if (file_exists($filePath)) { |
||
38 | return new SplFileInfo($filePath); |
||
39 | } |
||
40 | |||
41 | return null; |
||
42 | } |
||
43 | } |