Completed
Push — master ( d43f38...58ec5f )
by Jakub
01:47
created

getTestsDirectory()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 4
Bugs 1 Features 0
Metric Value
eloc 1
c 4
b 1
f 0
dl 0
loc 3
rs 10
ccs 1
cts 1
cp 1
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
function findVendorDirectory(): string
6
{
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