| Total Complexity | 3 |
| Total Lines | 73 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | abstract class Subcommand |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * The subcommand working directory. |
||
| 14 | * |
||
| 15 | * @var string |
||
| 16 | */ |
||
| 17 | const CWD = 'vendor/helick/local-server/docker'; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * The application instance. |
||
| 21 | * |
||
| 22 | * @var Application |
||
| 23 | */ |
||
| 24 | protected $application; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * Create a subcommand instance. |
||
| 28 | * |
||
| 29 | * @param Application $application |
||
| 30 | * |
||
| 31 | * @return void |
||
| 32 | */ |
||
| 33 | public function __construct(Application $application) |
||
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Invoke the subcommand. |
||
| 40 | * |
||
| 41 | * @param InputInterface $input |
||
| 42 | * @param OutputInterface $output |
||
| 43 | * |
||
| 44 | * @return void |
||
| 45 | */ |
||
| 46 | abstract public function __invoke(InputInterface $input, OutputInterface $output): void; |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @param string $command |
||
| 50 | * |
||
| 51 | * @return Process |
||
| 52 | */ |
||
| 53 | protected function runProcess(string $command): Process |
||
| 54 | { |
||
| 55 | $process = new Process( |
||
| 56 | $command, |
||
|
|
|||
| 57 | static::CWD, |
||
| 58 | $this->compileEnvironmentVariables() |
||
| 59 | ); |
||
| 60 | |||
| 61 | $process->setTimeout(0); |
||
| 62 | |||
| 63 | $process->run(function ($_, $buffer) { |
||
| 64 | echo $buffer; |
||
| 65 | }); |
||
| 66 | |||
| 67 | return $process; |
||
| 68 | } |
||
| 69 | |||
| 70 | /** |
||
| 71 | * @return array |
||
| 72 | */ |
||
| 73 | protected function compileEnvironmentVariables(): array |
||
| 83 | ]; |
||
| 84 | } |
||
| 86 |