| Conditions | 4 |
| Paths | 5 |
| Total Lines | 22 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 4 |
| Changes | 5 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 24 | 15 | public static function exec($command, array $params = array(), $escape=true) |
|
| 25 | { |
||
| 26 | 15 | if (empty($command)) { |
|
| 27 | 3 | throw new \InvalidArgumentException('Command line is empty'); |
|
| 28 | } |
||
| 29 | |||
| 30 | 12 | $command = self::bindParams($command, $params, $escape); |
|
| 31 | |||
| 32 | 12 | exec($command, $output, $code); |
|
| 33 | |||
| 34 | 12 | if (count($output) === 0) { |
|
| 35 | 3 | $output = $code; |
|
| 36 | 3 | } else { |
|
| 37 | 9 | $output = implode(PHP_EOL, $output); |
|
| 38 | } |
||
| 39 | |||
| 40 | 12 | if ($code !== 0) { |
|
| 41 | 3 | throw new CommandException($command, $output, $code); |
|
| 42 | } |
||
| 43 | |||
| 44 | 9 | return $output; |
|
| 45 | } |
||
| 46 | |||
| 89 |