Binary::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 12
ccs 7
cts 7
cp 1
rs 9.4285
c 1
b 0
f 0
cc 3
eloc 6
nc 3
nop 1
crap 3
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