Conditions | 4 |
Paths | 4 |
Total Lines | 28 |
Code Lines | 13 |
Lines | 7 |
Ratio | 25 % |
Tests | 14 |
CRAP Score | 4.0047 |
Changes | 0 |
1 | <?php |
||
41 | 3 | public function handle(Filesystem $filesystem, AddonEnvironment $env) |
|
42 | { |
||
43 | 3 | $addon_name = $this->argument('addon'); |
|
44 | |||
45 | 3 | $addon = $env->addon($addon_name); |
|
46 | |||
47 | // check addon |
||
48 | 3 | if ($addon === null) { |
|
49 | 1 | throw new UnexpectedValueException(sprintf('Addon "%s" is not found.', $addon_name)); |
|
50 | } |
||
51 | |||
52 | // confirm |
||
53 | 2 | $this->line('Addon name: '.$addon_name); |
|
54 | 2 | $this->line('Addon path: '.$addon->relativePath($this->laravel)); |
|
55 | |||
56 | 2 | View Code Duplication | if (!$this->option('force')) { |
|
|||
57 | 1 | if (!$this->confirm('Are you sure? [y/N]', false)) { |
|
58 | 1 | $this->comment('canceled'); |
|
59 | |||
60 | 1 | return; |
|
61 | } |
||
62 | } |
||
63 | |||
64 | // process |
||
65 | 1 | $filesystem->deleteDirectory($addon->path()); |
|
66 | |||
67 | 1 | $this->info(sprintf('Addon "%s" removed.', $addon_name)); |
|
68 | 1 | } |
|
69 | } |
||
70 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.