Conditions | 9 |
Paths | 25 |
Total Lines | 61 |
Code Lines | 44 |
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 |
||
36 | public function handle() |
||
37 | { |
||
38 | $this->info('Starting publication process of RBAC package parts...'); |
||
39 | |||
40 | $callArguments = ['--provider' => RbacServiceProvider::class]; |
||
41 | |||
42 | $dumpAutoload = false; |
||
43 | |||
44 | if ($this->option('only')) { |
||
45 | switch ($this->option('only')) { |
||
46 | case 'config': |
||
47 | $this->info('Publish just a part: config.'); |
||
48 | $callArguments['--tag'] = 'config'; |
||
49 | break; |
||
50 | |||
51 | case 'views': |
||
52 | $this->info('Publish just a part: views.'); |
||
53 | $callArguments['--tag'] = 'views'; |
||
54 | break; |
||
55 | |||
56 | case 'lang': |
||
57 | $this->info('Publish just a part: lang.'); |
||
58 | $callArguments['--tag'] = 'lang'; |
||
59 | break; |
||
60 | |||
61 | case 'migrations': |
||
62 | $this->info('Publish just a part: migrations.'); |
||
63 | $callArguments['--tag'] = 'migrations'; |
||
64 | $dumpAutoload = true; |
||
65 | break; |
||
66 | |||
67 | case 'seeders': |
||
68 | $this->info('Publish just a part: seeders.'); |
||
69 | $callArguments['--tag'] = 'seeders'; |
||
70 | $dumpAutoload = true; |
||
71 | break; |
||
72 | |||
73 | default: |
||
74 | $this->error('Invalid "only" argument value!'); |
||
75 | return; |
||
76 | break; |
||
|
|||
77 | } |
||
78 | |||
79 | } else { |
||
80 | $this->info('Publish all parts: config, views, lang, migrations, seeders.'); |
||
81 | $dumpAutoload = true; |
||
82 | } |
||
83 | |||
84 | if ($this->option('force')) { |
||
85 | $this->warn('Force publishing.'); |
||
86 | $callArguments['--force'] = true; |
||
87 | } |
||
88 | |||
89 | $this->call('vendor:publish', $callArguments); |
||
90 | |||
91 | if ($dumpAutoload) { |
||
92 | $this->info('Dumping the autoloaded files and reloading all new files.'); |
||
93 | $composer = $this->findComposer(); |
||
94 | $process = Process::fromShellCommandline($composer.' dump-autoload -o'); |
||
95 | $process->setTimeout(null); |
||
96 | $process->setWorkingDirectory(base_path())->run(); |
||
97 | } |
||
113 |
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.