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