Conditions | 4 |
Paths | 1 |
Total Lines | 14 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 4.0119 |
Changes | 2 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
6 | function findVendorDirectory(): string { |
||
7 | 1 | $recursionLimit = 10; |
|
8 | 1 | $findVendor = function ($dirName = "vendor/bin", $dir = __DIR__) use (&$findVendor, &$recursionLimit) { |
|
9 | 1 | $recursionLimit--; |
|
10 | 1 | if($recursionLimit < 1) { |
|
11 | throw new \Exception("Cannot find vendor directory."); |
||
12 | } |
||
13 | 1 | $found = $dir . "/$dirName"; |
|
14 | 1 | if(is_dir($found) || is_file($found)) { |
|
15 | 1 | return dirname($found); |
|
16 | } |
||
17 | 1 | return $findVendor($dirName, dirname($dir)); |
|
18 | 1 | }; |
|
19 | 1 | return $findVendor(); |
|
20 | } |
||
21 | ?> |