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