Completed
Pull Request — master (#59)
by Alessandro
05:30
created

PHPDbgBinFile   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 42
ccs 0
cts 13
cp 0
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getPhpDbgBin() 0 8 2
A isAvailable() 0 4 1
A getPhpDbgBinLocation() 0 7 1
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