| Conditions | 4 |
| Paths | 4 |
| Total Lines | 31 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 30 | public function handle(): void |
||
| 31 | { |
||
| 32 | // Check if package is listed in store |
||
| 33 | $name = $this->argument('name'); |
||
| 34 | $driver = $this->api->findDriver($this->argument('name')); |
||
|
|
|||
| 35 | |||
| 36 | if ($driver === null) { |
||
| 37 | $this->error('"'.$name.'" is not found in the available drivers list or is not yet supported by current FondBot version ('.FondBot::VERSION.').'); |
||
| 38 | |||
| 39 | exit(0); |
||
| 40 | } |
||
| 41 | |||
| 42 | if ($this->composer->installed($driver['package'])) { |
||
| 43 | $this->error('Driver is already installed.'); |
||
| 44 | |||
| 45 | return; |
||
| 46 | } |
||
| 47 | |||
| 48 | // Install driver |
||
| 49 | $this->info('Installing driver...'); |
||
| 50 | |||
| 51 | $result = $this->composer->install($driver['package'], function ($_, $line) use (&$output) { |
||
| 52 | $output .= $line; |
||
| 53 | }); |
||
| 54 | |||
| 55 | if ($result !== 0) { |
||
| 56 | $this->error($output); |
||
| 57 | exit($result); |
||
| 58 | } |
||
| 59 | |||
| 60 | $this->info('Driver installed. ✔'); |
||
| 61 | } |
||
| 63 |