Binary::getExecutable()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php declare(strict_types=1);
2
3
namespace Gitilicious\GitClient\Cli\Input;
4
5
use Gitilicious\GitClient\Cli\NotFoundException;
6
use Gitilicious\GitClient\Cli\PermissionDeniedException;
7
8
class Binary
9
{
10
    private $binary;
11
12 3
    public function __construct(string $binary)
13
    {
14 3
        if (!is_file($binary)) {
15 1
            throw new NotFoundException(sprintf('The executable `%s` could not be found.', $binary));
16
        }
17
18 2
        if (!is_executable($binary)) {
19 1
            throw new PermissionDeniedException(sprintf('`%s` is not executable.', $binary));
20
        }
21
22 1
        $this->binary = $binary;
23 1
    }
24
25 1
    public function getExecutable(): string
26
    {
27 1
        return $this->binary;
28
    }
29
}
30