Conditions | 2 |
Paths | 2 |
Total Lines | 23 |
Lines | 5 |
Ratio | 21.74 % |
Tests | 10 |
CRAP Score | 2.003 |
Changes | 0 |
1 | <?php |
||
37 | 10 | public function run($hostname, string $command, array $config = []) |
|
38 | { |
||
39 | $defaults = [ |
||
40 | 10 | 'timeout' => Deployer::getDefault('default_timeout', 300), |
|
41 | 'tty' => false, |
||
42 | ]; |
||
43 | 10 | $config = array_merge($defaults, $config); |
|
44 | |||
45 | 10 | $this->pop->command($hostname, $command); |
|
46 | |||
47 | 10 | View Code Duplication | if (method_exists('Symfony\Component\Process\Process', 'fromShellCommandline')) { |
48 | 10 | $process = Process::fromShellCommandline($command); |
|
49 | } else { |
||
50 | $process = new Process($command); |
||
51 | } |
||
52 | |||
53 | $process |
||
54 | 10 | ->setTimeout($config['timeout']) |
|
55 | 10 | ->setTty($config['tty']) |
|
56 | 10 | ->mustRun($this->pop->callback($hostname)); |
|
57 | |||
58 | 10 | return $process->getOutput(); |
|
59 | } |
||
60 | } |
||
61 |