Completed
Pull Request — master (#59)
by Alessandro
06:35
created

PHPDbgBinFile::isAvailable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Paraunit\Configuration;
4
5
use Symfony\Component\Process\Process;
6
7
/**
8
 * Class PHPDbgBinFile
9
 * @package Paraunit\Configuration
10
 */
11
class PHPDbgBinFile
12
{
13
    /** @var  string Realpath to the PHPDbg bin location */
14
    private $phpDbgBin;
15
16
    /**
17
     * PHPDbgBinFile constructor.
18
     */
19
    public function __construct()
20
    {
21
        $this->phpDbgBin = $this->getPhpDbgBinLocation();
22
    }
23
24
    /**
25
     * @return string
26
     * @throws \Exception
27
     */
28
    public function getPhpDbgBin()
29
    {
30
        if (! $this->isAvailable()) {
31
            throw new \RuntimeException('PHPDbg is not available!');
32
        }
33
34
        return $this->phpDbgBin;
35
    }
36
37
    public function isAvailable()
38
    {
39
        return file_exists($this->phpDbgBin);
40
    }
41
42
    /**
43
     * @return string
44
     */
45
    private function getPhpDbgBinLocation()
46
    {
47
        $locator = new Process('command -v phpdbg');
48
        $locator->run();
49
50
        return (string) $locator->getOutput();
51
    }
52
}
53