We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 5 |
| Paths | 5 |
| Total Lines | 54 |
| Code Lines | 29 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| 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 |
||
| 46 | public function handle() |
||
| 47 | { |
||
| 48 | // Check if it is installed |
||
| 49 | if ($this->isInstalled()) { |
||
| 50 | $this->newLine(); |
||
| 51 | $this->line(sprintf(' %s was already installed', self::$addon['name']), 'fg=red'); |
||
| 52 | $this->newLine(); |
||
| 53 | |||
| 54 | return; |
||
| 55 | } |
||
| 56 | |||
| 57 | $this->newLine(); |
||
| 58 | $this->infoBlock('Connecting to the Backpack add-on repository'); |
||
| 59 | |||
| 60 | // Check if repositories exists |
||
| 61 | $this->composerRepositories(); |
||
| 62 | |||
| 63 | // Check for authentication |
||
| 64 | $this->checkForAuthentication(); |
||
| 65 | |||
| 66 | $this->newLine(); |
||
| 67 | $this->progressBlock($this->description); |
||
| 68 | |||
| 69 | // Require package |
||
| 70 | try { |
||
| 71 | $this->composerRequire('backpack/devtools', ['--dev', '--with-all-dependencies']); |
||
| 72 | } catch (\Throwable $e) { |
||
| 73 | $this->errorProgressBlock(); |
||
| 74 | $this->line(' '.$e->getMessage(), 'fg=red'); |
||
| 75 | $this->newLine(); |
||
| 76 | |||
| 77 | return; |
||
| 78 | } |
||
| 79 | |||
| 80 | // Display general error in case it failed |
||
| 81 | if (! $this->isInstalled()) { |
||
| 82 | $this->errorProgressBlock(); |
||
| 83 | $this->note('For further information please check the log file.'); |
||
| 84 | $this->note('You can also follow the manual installation process documented in https://backpackforlaravel.com/addons/'); |
||
| 85 | $this->newLine(); |
||
| 86 | |||
| 87 | return; |
||
| 88 | } |
||
| 89 | |||
| 90 | // Finish |
||
| 91 | $this->closeProgressBlock(); |
||
| 92 | $this->newLine(); |
||
| 93 | |||
| 94 | // manually include the command in the run-time |
||
| 95 | if (! class_exists(\Backpack\DevTools\Console\Commands\InstallDevTools::class)) { |
||
| 96 | include base_path('vendor/backpack/devtools/src/Console/Commands/InstallDevTools.php'); |
||
| 97 | } |
||
| 98 | |||
| 99 | $this->call(\Backpack\DevTools\Console\Commands\InstallDevTools::class); |
||
| 100 | } |
||
| 107 |