We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
Conditions | 12 |
Paths | 76 |
Total Lines | 96 |
Lines | 0 |
Ratio | 0 % |
Changes | 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 | /* |
||
39 | * "ask" comes by default, when no option is provided, like: "backpack:install" |
||
40 | * https://laravel.com/docs/6.0/artisan#options |
||
41 | */ |
||
42 | $shouldInstallElfinder = false; |
||
43 | |||
44 | if ($this->option('elfinder') == 'ask') { |
||
45 | $shouldInstallElfinder = $this->confirm('Install barryvdh/laravel-elfinder to provide an admin interface for File Management?', false); |
||
46 | } elseif ($this->option('elfinder') == 'no') { |
||
47 | $shouldInstallElfinder = false; |
||
48 | } elseif ($this->option('elfinder') == 'yes') { |
||
49 | $shouldInstallElfinder = true; |
||
50 | } else { |
||
51 | $this->error('Option not recognized: '.$this->option('elfinder')); |
||
52 | |||
53 | return false; |
||
54 | } |
||
55 | |||
56 | $this->progressBar = $this->output->createProgressBar($shouldInstallElfinder ? 11 : 6); |
||
57 | $this->progressBar->minSecondsBetweenRedraws(0); |
||
58 | $this->progressBar->maxSecondsBetweenRedraws(120); |
||
59 | $this->progressBar->setRedrawFrequency(1); |
||
60 | |||
61 | $this->progressBar->start(); |
||
62 | |||
63 | $this->info(' Backpack installation started. Please wait...'); |
||
64 | $this->progressBar->advance(); |
||
65 | |||
66 | $this->line(' Publishing configs, langs, views, js and css files'); |
||
67 | $this->executeArtisanProcess('vendor:publish', [ |
||
68 | '--provider' => 'Backpack\CRUD\BackpackServiceProvider', |
||
69 | '--tag' => 'minimum' |
||
70 | ]); |
||
71 | |||
72 | $this->line(' Publishing config for notifications - prologue/alerts'); |
||
73 | $this->executeArtisanProcess('vendor:publish', [ |
||
74 | '--provider' => 'Prologue\Alerts\AlertsServiceProvider' |
||
75 | ]); |
||
76 | |||
77 | $this->line(" Generating users table (using Laravel's default migrations)"); |
||
78 | $this->executeArtisanProcess('migrate'); |
||
79 | |||
80 | $this->line(" Creating App\Models\BackpackUser.php"); |
||
81 | $this->executeArtisanProcess('backpack:publish-user-model'); |
||
82 | |||
83 | $this->line(" Creating App\Http\Middleware\CheckIfAdmin.php"); |
||
84 | $this->executeArtisanProcess('backpack:publish-middleware'); |
||
85 | |||
86 | // elFinder steps |
||
87 | if ($shouldInstallElfinder) { |
||
88 | $this->line(' Installing barryvdh/laravel-elfinder'); |
||
89 | $this->executeProcess(['composer', 'require', 'barryvdh/laravel-elfinder']); |
||
90 | |||
91 | $this->line(' Creating uploads directory'); |
||
92 | switch (DIRECTORY_SEPARATOR) { |
||
93 | case '/': // unix |
||
94 | $createUploadDirectoryCommand = ['mkdir', '-p', 'public/uploads']; |
||
95 | break; |
||
96 | case '\\': // windows |
||
97 | if (! file_exists('public\uploads')) { |
||
98 | $createUploadDirectoryCommand = ['mkdir', 'public\uploads']; |
||
99 | } |
||
100 | break; |
||
101 | } |
||
102 | if (isset($createUploadDirectoryCommand)) { |
||
103 | $this->executeProcess($createUploadDirectoryCommand); |
||
104 | } |
||
105 | |||
106 | $this->line(' Publishing elFinder assets'); |
||
107 | $this->executeArtisanProcess('elfinder:publish'); |
||
108 | |||
109 | $this->line(' Publishing custom elfinder views'); |
||
110 | $this->executeArtisanProcess('vendor:publish', [ |
||
111 | '--provider' => 'Backpack\CRUD\BackpackServiceProvider', |
||
112 | '--tag' => 'elfinder' |
||
113 | ]); |
||
114 | |||
115 | $this->line(' Adding sidebar menu item for File Manager'); |
||
116 | switch (DIRECTORY_SEPARATOR) { |
||
117 | case '/': // unix |
||
118 | $this->executeArtisanProcess('backpack:add-sidebar-content', [ |
||
119 | 'code' => '<li class="nav-item"><a class="nav-link" href="{{ backpack_url(\'elfinder\') }}\"><i class="nav-icon fa fa-files-o"></i> <span>{{ trans(\'backpack::crud.file_manager\') }}</span></a></li>']); |
||
120 | break; |
||
121 | case '\\': // windows |
||
122 | $this->executeArtisanProcess('backpack:add-sidebar-content', [ |
||
123 | 'code' => '<li class="nav-item"><a class="nav-link" href=""{{ backpack_url(\'elfinder\') }}""><i class=""nav-icon fa fa-files-o""></i> <span>{{ trans(\'backpack::crud.file_manager\') }}</span></a></li>']); |
||
124 | break; |
||
125 | } |
||
126 | } |
||
127 | // end of elFinder steps |
||
128 | |||
129 | $this->progressBar->finish(); |
||
130 | $this->info(' Backpack installation finished.'); |
||
131 | } |
||
132 | |||
221 |
This check looks for the generic type
array
as a return type and suggests a more specific type. This type is inferred from the actual code.