Conditions | 4 |
Paths | 1 |
Total Lines | 14 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 4.016 |
Changes | 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 | if(!$recursionLimit--) { |
|
10 | throw new \Exception("Cannot find vendor directory."); |
||
11 | } |
||
12 | 1 | $found = $dir . "/$dirName"; |
|
13 | 1 | if(is_dir($found) || is_file($found)) { |
|
14 | 1 | return dirname($found); |
|
15 | } |
||
16 | 1 | return $findVendor($dirName, dirname($dir)); |
|
17 | 1 | }; |
|
18 | 1 | return $findVendor(); |
|
19 | } |
||
20 | ?> |