Conditions | 5 |
Paths | 9 |
Total Lines | 23 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
19 | public function execute(string $command, bool $mergeStdErr = true) |
||
20 | { |
||
21 | if (empty($command)) { |
||
22 | throw new InvalidArgumentException('Command line is empty'); |
||
23 | } |
||
24 | |||
25 | if ($mergeStdErr) { |
||
26 | $command .= ' 2>&1'; |
||
27 | } |
||
28 | |||
29 | exec($command, $output, $code); |
||
30 | |||
31 | if (count($output) === 0) { |
||
32 | $output = $code; |
||
33 | } else { |
||
34 | $output = implode(PHP_EOL, $output); |
||
35 | } |
||
36 | |||
37 | if ($code !== 0) { |
||
38 | throw new CommandException($command, $output, $code); |
||
39 | } |
||
40 | |||
41 | return $output; |
||
42 | } |
||
44 |