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