ShellWhich::__invoke()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 2
nop 1
dl 0
loc 9
ccs 7
cts 7
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpCfdi\RfcLinc\Util;
6
7
class ShellWhich
8
{
9 4
    public function __invoke(string $executable): string
10
    {
11 4
        $lines = [];
12 4
        $return = -1;
13 4
        $output = (string) exec('which ' . escapeshellarg($executable), $lines, $return);
14 4
        if (0 !== (int) $return) {
15 1
            return '';
16
        }
17 3
        return $output;
18
    }
19
}
20