We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
Conditions | 6 |
Paths | 9 |
Total Lines | 63 |
Code Lines | 30 |
Lines | 0 |
Ratio | 0 % |
Changes | 12 | ||
Bugs | 5 | 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->progressBar = $this->output->createProgressBar(45); |
||
39 | $this->progressBar->minSecondsBetweenRedraws(0); |
||
40 | $this->progressBar->maxSecondsBetweenRedraws(120); |
||
41 | $this->progressBar->setRedrawFrequency(1); |
||
42 | $this->progressBar->start(); |
||
43 | |||
44 | $this->info(' Requiring DevTools. Please wait...'); |
||
45 | $this->progressBar->advance(); |
||
46 | |||
47 | // Check if repositories exists |
||
48 | $this->composerRepositories(); |
||
49 | |||
50 | // Check for authentication |
||
51 | $this->checkForAuthentication(); |
||
52 | |||
53 | // Require DevTools |
||
54 | $this->requireDevTools(); |
||
55 | |||
56 | // Check if devtools is installed |
||
57 | $tries = 2; |
||
58 | while (! file_exists('vendor/backpack/devtools/src/Console/Commands/InstallDevTools.php')) { |
||
59 | // Abort at nth try |
||
60 | if (--$tries === 0) { |
||
61 | return $this->error(' DevTools was not installed.'); |
||
|
|||
62 | } |
||
63 | |||
64 | // Restart progress bar |
||
65 | $this->error('Please make sure your access token is correct.'); |
||
66 | $this->progressBar->start(); |
||
67 | |||
68 | // Clear authentication |
||
69 | if (File::exists('auth.json')) { |
||
70 | $auth = json_decode(File::get('auth.json')); |
||
71 | if ($auth->{'http-basic'}->{'backpackforlaravel.com'} ?? false) { |
||
72 | unset($auth->{'http-basic'}->{'backpackforlaravel.com'}); |
||
73 | |||
74 | File::put('auth.json', json_encode($auth, JSON_PRETTY_PRINT)); |
||
75 | } |
||
76 | } |
||
77 | |||
78 | // Check for authentication |
||
79 | $this->checkForAuthentication(); |
||
80 | |||
81 | // Require DevTools |
||
82 | $this->requireDevTools(); |
||
83 | } |
||
84 | |||
85 | // Finish |
||
86 | $this->progressBar->finish(); |
||
87 | $this->info(' DevTools is now required.'); |
||
88 | |||
89 | // DevTools inside installer |
||
90 | $this->info(''); |
||
91 | $this->info(' Now running the DevTools installation command.'); |
||
92 | |||
93 | // manually include the command in the run-time |
||
94 | if (! class_exists(\Backpack\DevTools\Console\Commands\InstallDevTools::class)) { |
||
95 | include base_path('vendor/backpack/devtools/src/Console/Commands/InstallDevTools.php'); |
||
96 | } |
||
97 | |||
98 | $this->call(\Backpack\DevTools\Console\Commands\InstallDevTools::class); |
||
99 | } |
||
208 |
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.