Conditions | 4 |
Paths | 4 |
Total Lines | 32 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 20 |
Changes | 0 |
1 | <?php |
||
18 | public function handle(API $api, Composer $composer): void |
||
19 | { |
||
20 | // Check if package is listed in store |
||
21 | $name = $this->argument('name'); |
||
22 | $driver = $api->findDriver($this->argument('name')); |
||
|
|||
23 | |||
24 | if ($driver === null) { |
||
25 | $this->error('"'.$name.'" is not found in the available drivers list.'); |
||
26 | |||
27 | exit(0); |
||
28 | } |
||
29 | |||
30 | if ($composer->installed($driver['package'])) { |
||
31 | $this->error('Driver is already installed.'); |
||
32 | |||
33 | return; |
||
34 | } |
||
35 | |||
36 | // Install driver |
||
37 | $this->info('Installing driver...'); |
||
38 | |||
39 | $result = $composer->install($driver['package'], function ($_, $line) use (&$output) { |
||
40 | $output .= $line; |
||
41 | }); |
||
42 | |||
43 | if ($result !== 0) { |
||
44 | $this->error($output); |
||
45 | exit($result); |
||
46 | } |
||
47 | |||
48 | $this->info('Driver installed.'); |
||
49 | } |
||
50 | } |
||
51 |
This check looks at variables that are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.