Passed
Push — master ( b8e16f...40853b )
by Carlos C
02:32
created

ShellWhich   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 90%

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 9
cts 10
cp 0.9
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 13 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpCfdi\RfcLinc\Util;
6
7
class ShellWhich
8
{
9 14
    public function __invoke(string $executable): string
10
    {
11 14
        $output = [];
12 14
        $return = -1;
13 14
        exec('which ' . escapeshellarg($executable), $output, $return);
14 14
        if (0 !== (int) $return) {
15 1
            return '';
16
        }
17 13
        $count = count($output);
18 13
        if (0 === $count) {
19
            return '';
20
        }
21 13
        return $output[$count - 1];
22
    }
23
}
24