Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | <?php |
||
11 | class AdminServiceProvider extends ServiceProvider |
||
12 | { |
||
13 | /** |
||
14 | * @var array |
||
15 | */ |
||
16 | protected $commands = [ |
||
17 | Console\AdminCommand::class, |
||
18 | Console\MakeCommand::class, |
||
19 | Console\ControllerCommand::class, |
||
20 | Console\MenuCommand::class, |
||
21 | Console\InstallCommand::class, |
||
22 | Console\PublishCommand::class, |
||
23 | Console\UninstallCommand::class, |
||
24 | Console\ImportCommand::class, |
||
25 | Console\CreateUserCommand::class, |
||
26 | Console\ResetPasswordCommand::class, |
||
27 | Console\ExtendCommand::class, |
||
28 | Console\ExportSeedCommand::class, |
||
29 | Console\MinifyCommand::class, |
||
30 | Console\FormCommand::class, |
||
31 | Console\PermissionCommand::class, |
||
32 | Console\ActionCommand::class, |
||
33 | Console\GenerateMenuCommand::class, |
||
34 | Console\ConfigCommand::class, |
||
35 | ]; |
||
36 | |||
37 | /** |
||
38 | * The application's route middleware. |
||
39 | * |
||
40 | * @var array |
||
41 | */ |
||
42 | protected $routeMiddleware = [ |
||
43 | 'admin.auth' => Middleware\Authenticate::class, |
||
44 | 'admin.pjax' => Middleware\Pjax::class, |
||
45 | 'admin.log' => Middleware\LogOperation::class, |
||
46 | 'admin.permission' => Middleware\Permission::class, |
||
47 | 'admin.bootstrap' => Middleware\Bootstrap::class, |
||
48 | 'admin.session' => Middleware\Session::class, |
||
49 | ]; |
||
50 | |||
51 | /** |
||
52 | * The application's route middleware groups. |
||
53 | * |
||
54 | * @var array |
||
55 | */ |
||
56 | protected $middlewareGroups = [ |
||
57 | 'admin' => [ |
||
58 | 'admin.auth', |
||
59 | 'admin.pjax', |
||
60 | 'admin.log', |
||
61 | 'admin.bootstrap', |
||
62 | 'admin.permission', |
||
63 | // 'admin.session', |
||
64 | ], |
||
65 | ]; |
||
66 | |||
67 | /** |
||
68 | * Boot the service provider. |
||
69 | * |
||
70 | * @return void |
||
71 | */ |
||
72 | public function boot() |
||
94 | |||
95 | /** |
||
96 | * Force to set https scheme if https enabled. |
||
97 | * |
||
98 | * @return void |
||
99 | */ |
||
100 | protected function ensureHttps() |
||
107 | |||
108 | /** |
||
109 | * Register the package's publishable resources. |
||
110 | * |
||
111 | * @return void |
||
112 | */ |
||
113 | protected function registerPublishing() |
||
122 | |||
123 | /** |
||
124 | * Remove default feature of double encoding enable in laravel 5.6 or later. |
||
125 | * |
||
126 | * @return void |
||
127 | */ |
||
128 | protected function compatibleBlade() |
||
136 | |||
137 | /** |
||
138 | * Extends laravel router. |
||
139 | */ |
||
140 | protected function macroRouter() |
||
160 | |||
161 | /** |
||
162 | * Register the service provider. |
||
163 | * |
||
164 | * @return void |
||
165 | */ |
||
166 | public function register() |
||
176 | |||
177 | /** |
||
178 | * Setup auth configuration. |
||
179 | * |
||
180 | * @return void |
||
181 | */ |
||
182 | protected function loadAdminAuthConfig() |
||
186 | |||
187 | /** |
||
188 | * Register the route middleware. |
||
189 | * |
||
190 | * @return void |
||
191 | */ |
||
192 | protected function registerRouteMiddleware() |
||
204 | } |
||
205 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.