Passed
Push — master ( 92144b...45825a )
by Jakub
03:43
created

getTestsDirectory()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 1 Features 0
Metric Value
cc 2
eloc 3
nc 2
nop 0
dl 0
loc 5
rs 9.4285
c 4
b 1
f 0
1
<?php
2
declare(strict_types=1);
3
4
function findVendorDirectory(): string {
5
  $recursionLimit = 10;
6
  $findVendor = function ($dirName = "vendor/bin", $dir = __DIR__) use (&$findVendor, &$recursionLimit) {
7
    if (!$recursionLimit--) {
8
      throw new \Exception("Cannot find vendor directory.");
9
    }
10
    $found = $dir . "/$dirName";
11
    if (is_dir($found) || is_file($found)) {
12
      return dirname($found);
13
    }
14
    return $findVendor($dirName, dirname($dir));
15
  };
16
  return $findVendor();
17
}
18
19
function getTestsDirectory(): string {
20
  if(!isset($argv[1])) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $argv seems to never exist and therefore isset should always be false.
Loading history...
21
    return dirname(findVendorDirectory()) . "/tests";
22
  }
23
  return $argv[1];
24
}
25
?>