Conditions | 9 |
Paths | 25 |
Total Lines | 60 |
Code Lines | 43 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
34 | public function handle() |
||
35 | { |
||
36 | $this->info('Starting publication process of Uploader package parts...'); |
||
37 | |||
38 | $callArguments = ['--provider' => UploadServiceProvider::class]; |
||
39 | |||
40 | $dumpAutoload = false; |
||
41 | |||
42 | if ($this->option('only')) { |
||
43 | switch ($this->option('only')) { |
||
44 | case 'assets': |
||
45 | $this->info('Publish just a part: assets.'); |
||
46 | $callArguments['--tag'] = 'assets'; |
||
47 | break; |
||
48 | |||
49 | case 'config': |
||
50 | $this->info('Publish just a part: config.'); |
||
51 | $callArguments['--tag'] = 'config'; |
||
52 | break; |
||
53 | |||
54 | case 'views': |
||
55 | $this->info('Publish just a part: views.'); |
||
56 | $callArguments['--tag'] = 'views'; |
||
57 | break; |
||
58 | |||
59 | case 'lang': |
||
60 | $this->info('Publish just a part: lang.'); |
||
61 | $callArguments['--tag'] = 'lang'; |
||
62 | break; |
||
63 | |||
64 | case 'migrations': |
||
65 | $this->info('Publish just a part: migrations.'); |
||
66 | $callArguments['--tag'] = 'migrations'; |
||
67 | $dumpAutoload = true; |
||
68 | break; |
||
69 | |||
70 | default: |
||
71 | $this->error('Invalid "only" argument value!'); |
||
72 | return; |
||
73 | break; |
||
|
|||
74 | } |
||
75 | |||
76 | } else { |
||
77 | $this->info('Publish all parts: assets, config, views, lang, migrations.'); |
||
78 | $dumpAutoload = true; |
||
79 | } |
||
80 | |||
81 | if ($this->option('force')) { |
||
82 | $this->warn('Force publishing.'); |
||
83 | $callArguments['--force'] = true; |
||
84 | } |
||
85 | |||
86 | $this->call('vendor:publish', $callArguments); |
||
87 | |||
88 | if ($dumpAutoload) { |
||
89 | $this->info('Dumping the autoloaded files and reloading all new files.'); |
||
90 | $composer = $this->findComposer(); |
||
91 | $process = Process::fromShellCommandline($composer . ' dump-autoload -o'); |
||
92 | $process->setTimeout(null); |
||
93 | $process->setWorkingDirectory(base_path())->run(); |
||
94 | } |
||
110 |
The
break
statement is not necessary if it is preceded for example by areturn
statement:If you would like to keep this construct to be consistent with other
case
statements, you can safely mark this issue as a false-positive.