We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
Conditions | 5 |
Paths | 2 |
Total Lines | 53 |
Code Lines | 31 |
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 |
||
35 | public function handle() |
||
36 | { |
||
37 | $this->progressBar = $this->output->createProgressBar(15); |
||
38 | $this->progressBar->minSecondsBetweenRedraws(0); |
||
39 | $this->progressBar->maxSecondsBetweenRedraws(120); |
||
40 | $this->progressBar->setRedrawFrequency(1); |
||
41 | |||
42 | $this->progressBar->start(); |
||
43 | |||
44 | $this->info(' DevTools installation started. Please wait...'); |
||
45 | $this->progressBar->advance(); |
||
46 | |||
47 | // Check if auth exists |
||
48 | $details = null; |
||
49 | $process = new Process(['composer', 'config', 'http-basic.backpackforlaravel.com']); |
||
50 | $process->run(function ($type, $buffer) use (&$details) { |
||
51 | if ($type !== Process::ERR && $buffer !== '') { |
||
52 | $details = json_decode($buffer); |
||
53 | } |
||
54 | $this->progressBar->advance(); |
||
55 | }); |
||
56 | |||
57 | // Create an auth.json file |
||
58 | if (! $details) { |
||
59 | $this->info(' Creating auth.json file with DevTools auth details'); |
||
60 | |||
61 | $this->line(' (Find your access token details on https://backpackforlaravel.com/user/tokens)'); |
||
62 | $username = $this->ask('Access token username'); |
||
63 | $password = $this->ask('Access token password'); |
||
64 | |||
65 | $process = new Process(['composer', 'config', 'http-basic.backpackforlaravel.com', $username, $password]); |
||
66 | $process->run(function ($type, $buffer) { |
||
|
|||
67 | if ($type === Process::ERR) { |
||
68 | $this->error('Could not write to auth.json file.'); |
||
69 | } |
||
70 | $this->progressBar->advance(); |
||
71 | }); |
||
72 | } |
||
73 | |||
74 | // Require package |
||
75 | $process = new Process(['composer', 'require', '--dev', 'backpack/devtools']); |
||
76 | $process->run(function ($type, $buffer) { |
||
77 | $this->progressBar->advance(); |
||
78 | }); |
||
79 | |||
80 | // Finish |
||
81 | $this->progressBar->finish(); |
||
82 | $this->info(' DevTools installation finished.'); |
||
83 | |||
84 | // DevTools inside installer |
||
85 | $this->info(''); |
||
86 | $this->info(' DevTools requirements started. Please wait...'); |
||
87 | $this->call('backpack:devtools:install'); |
||
88 | } |
||
90 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.