Completed
Push — master ( 3d6945...1b942f )
by Jakub
03:24
created

functions.php ➔ findVendorDirectory()   A

Complexity

Conditions 4
Paths 1

Size

Total Lines 14
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 4.016

Importance

Changes 0
Metric Value
cc 4
eloc 10
nc 1
nop 0
dl 0
loc 14
ccs 9
cts 10
cp 0.9
crap 4.016
rs 9.2
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Nexendrie\SiteGenerator;
5
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
?>