Failed Conditions
Push — master ( 85c284...561f65 )
by Sébastien
02:44
created

AbstractProcess::ensureBinaryExists()   A

Complexity

Conditions 4
Paths 6

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 5.4042

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 14
c 0
b 0
f 0
ccs 5
cts 9
cp 0.5556
rs 9.9666
cc 4
nc 6
nop 0
crap 5.4042
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Soluble\MediaTools\Process;
6
7
use Symfony\Component\Process\Exception\ProcessFailedException;
8
use Symfony\Component\Process\Process;
9
10
abstract class AbstractProcess
11
{
12
    abstract public function buildCommand(array $arguments): string;
13
14
    abstract public function getBinary(): string;
15
16
    public function runCommand(string $cmd): string
17
    {
18
        $process = new Process($cmd);
19
        try {
20
            $process->mustRun();
21
22
            return $process->getOutput();
23
        } catch (ProcessFailedException $e) {
24
            throw $e;
25
        }
26
    }
27
}
28