Conditions | 4 |
Paths | 4 |
Total Lines | 23 |
Code Lines | 10 |
Lines | 7 |
Ratio | 30.43 % |
Tests | 11 |
CRAP Score | 4.0092 |
Changes | 2 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
39 | 3 | public function handle(Filesystem $filesystem, AddonEnvironment $env) |
|
40 | { |
||
41 | 3 | $addonName = $this->argument('name'); |
|
42 | |||
43 | // check addon |
||
44 | 3 | if (!$env->exists($addonName)) { |
|
|
|||
45 | 1 | throw new UnexpectedValueException(sprintf('Addon "%s" is not found.', $addonName)); |
|
46 | } |
||
47 | |||
48 | // confirm |
||
49 | 2 | View Code Duplication | if (!$this->option('force')) { |
50 | 1 | if (!$this->confirm('Are you sure? [y/N]', false)) { |
|
51 | 1 | $this->comment('canceled'); |
|
52 | |||
53 | 1 | return; |
|
54 | } |
||
55 | } |
||
56 | |||
57 | // process |
||
58 | 1 | $filesystem->deleteDirectory($env->path($addonName)); |
|
59 | |||
60 | 1 | $this->info(sprintf('Addon "%s" removed.', $addonName)); |
|
61 | 1 | } |
|
62 | } |
||
63 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.