| Total Complexity | 6 |
| Total Lines | 66 |
| Duplicated Lines | 0 % |
| Coverage | 28.57% |
| Changes | 0 | ||
| 1 | <?php |
||
| 9 | class Cli implements CliContract |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * Execute a command. |
||
| 13 | * |
||
| 14 | * @param string $command |
||
| 15 | * |
||
| 16 | * @return string |
||
| 17 | */ |
||
| 18 | 2 | public function exec($command) |
|
| 19 | { |
||
| 20 | 2 | $process = new Process($command); |
|
| 21 | 2 | $process->run(); |
|
| 22 | |||
| 23 | 2 | return $process->getOutput(); |
|
| 24 | } |
||
| 25 | |||
| 26 | /** |
||
| 27 | * Execute a command in real time. |
||
| 28 | * |
||
| 29 | * @param string $command |
||
| 30 | * |
||
| 31 | * @return string |
||
| 32 | */ |
||
| 33 | public function execRealTime($command) |
||
| 34 | { |
||
| 35 | $process = new Process($command); |
||
| 36 | |||
| 37 | try { |
||
| 38 | $process->mustRun(function ($type, $buffer) { |
||
| 39 | echo $buffer; |
||
| 40 | }); |
||
| 41 | } catch (ProcessFailedException $e) { |
||
| 42 | echo $e->getMessage(); |
||
| 43 | } |
||
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
| 47 | * Execute a command and allow the user to interact with it. |
||
| 48 | * |
||
| 49 | * @param string $command |
||
| 50 | * |
||
| 51 | * @return void |
||
| 52 | */ |
||
| 53 | public function passthru($command) |
||
| 64 | } |
||
| 65 | } |
||
| 66 | |||
| 67 | /** |
||
| 68 | * Return the current working directory. |
||
| 69 | * |
||
| 70 | * @return string |
||
| 71 | */ |
||
| 72 | 1 | public function currentWorkingDirectory() |
|
| 77 |