ShellExecutor   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 90.91%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 0
cbo 1
dl 0
loc 32
ccs 10
cts 11
cp 0.9091
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 4 1
A execute() 0 15 2
1
<?php
2
3
namespace Velikonja\LabbyBundle\Executor;
4
5
use Symfony\Component\Console\Output\OutputInterface;
6
use Symfony\Component\Process\Process;
7
8
class ShellExecutor implements ExecutorInterface
9
{
10
    /**
11
     * @param string               $command
12
     * @param OutputInterface|null $output
13
     *
14
     * @return int
15
     */
16 1
    public function execute($command, OutputInterface $output = null)
17
    {
18 1
        $process = new Process($command);
19 1
        $process->setTimeout(120);
20
21 1
        $process->run(function ($type, $buffer) use ($output) {
22 1
            $output->writeln($buffer);
23 1
        });
24
25 1
        if (!$process->isSuccessful()) {
26
            throw new \RuntimeException($process->getErrorOutput());
27
        }
28
29 1
        return $process->getExitCode();
30
    }
31
32
    /**
33
     * @return string
34
     */
35 4
    public function getName()
36
    {
37 4
        return 'shell';
38
    }
39
}
40