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 |
||
37 | class ApplicationServiceProvider implements ServiceProviderInterface |
||
38 | { |
||
39 | /** |
||
40 | * Registers the service provider with a DI container. |
||
41 | * |
||
42 | * @param Container $container The DI container. |
||
43 | * |
||
44 | * @return void |
||
45 | */ |
||
46 | 1 | public function register(Container $container) |
|
102 | |||
103 | /** |
||
104 | * Get the Analytics class service |
||
105 | * |
||
106 | * @param Container $container The DI container. |
||
107 | * |
||
108 | * @return Analytics |
||
109 | */ |
||
110 | 1 | public function getAnalyticsService(Container $container) |
|
114 | |||
115 | /** |
||
116 | * Get the Cache\ClearCommand class service |
||
117 | * |
||
118 | * @param Container $container The DI container. |
||
119 | * |
||
120 | * @return AppCommands\Cache\ClearCommand |
||
121 | */ |
||
122 | 1 | View Code Duplication | public function getCacheClearCommandService(Container $container) : AppCommands\Cache\ClearCommand |
131 | |||
132 | /** |
||
133 | * Get the CLI application service |
||
134 | * |
||
135 | * @param Container $container The DI container. |
||
136 | * |
||
137 | * @return CliApplication |
||
138 | */ |
||
139 | 1 | public function getCliApplicationService(Container $container) : CliApplication |
|
154 | |||
155 | /** |
||
156 | * Get the CliInput class service |
||
157 | * |
||
158 | * @param Container $container The DI container. |
||
159 | * |
||
160 | * @return JoomlaApplication\Cli\CliInput |
||
161 | */ |
||
162 | 1 | public function getCliInputService(Container $container) : JoomlaApplication\Cli\CliInput |
|
166 | |||
167 | /** |
||
168 | * Get the CliOutput class service |
||
169 | * |
||
170 | * @param Container $container The DI container. |
||
171 | * |
||
172 | * @return JoomlaApplication\Cli\CliOutput |
||
173 | */ |
||
174 | 1 | public function getCliOutputService(Container $container) : JoomlaApplication\Cli\Output\Stdout |
|
178 | |||
179 | /** |
||
180 | * Get the ColorProcessor class service |
||
181 | * |
||
182 | * @param Container $container The DI container. |
||
183 | * |
||
184 | * @return JoomlaApplication\Cli\Output\Processor\ColorProcessor |
||
185 | */ |
||
186 | 1 | public function getColorProcessorService(Container $container) : JoomlaApplication\Cli\Output\Processor\ColorProcessor |
|
203 | |||
204 | /** |
||
205 | * Get the console service |
||
206 | * |
||
207 | * @param Container $container The DI container. |
||
208 | * |
||
209 | * @return Console |
||
210 | */ |
||
211 | 1 | public function getConsoleService(Container $container) : Console |
|
218 | |||
219 | /** |
||
220 | * Get the Database\MigrateCommand class service |
||
221 | * |
||
222 | * @param Container $container The DI container. |
||
223 | * |
||
224 | * @return AppCommands\Database\MigrateCommand |
||
225 | */ |
||
226 | 1 | public function getDatabaseMigrateCommandService(Container $container) : AppCommands\Database\MigrateCommand |
|
236 | |||
237 | /** |
||
238 | * Get the Database\StatusCommand class service |
||
239 | * |
||
240 | * @param Container $container The DI container. |
||
241 | * |
||
242 | * @return AppCommands\Database\StatusCommand |
||
243 | */ |
||
244 | 1 | View Code Duplication | public function getDatabaseStatusCommandService(Container $container) : AppCommands\Database\StatusCommand |
253 | |||
254 | /** |
||
255 | * Get the DisplayControllerGet class service |
||
256 | * |
||
257 | * @param Container $container The DI container. |
||
258 | * |
||
259 | * @return DisplayControllerGet |
||
260 | */ |
||
261 | 1 | View Code Duplication | public function getDisplayControllerGetService(Container $container) : DisplayControllerGet |
273 | |||
274 | /** |
||
275 | * Get the HelpCommand class service |
||
276 | * |
||
277 | * @param Container $container The DI container. |
||
278 | * |
||
279 | * @return AppCommands\HelpCommand |
||
280 | */ |
||
281 | 1 | View Code Duplication | public function getHelpCommandService(Container $container) : AppCommands\HelpCommand |
290 | |||
291 | /** |
||
292 | * Get the Input\Cli class service |
||
293 | * |
||
294 | * @param Container $container The DI container. |
||
295 | * |
||
296 | * @return Cli |
||
297 | */ |
||
298 | 1 | public function getInputCliService(Container $container) : Cli |
|
302 | |||
303 | /** |
||
304 | * Get the Input class service |
||
305 | * |
||
306 | * @param Container $container The DI container. |
||
307 | * |
||
308 | * @return Input |
||
309 | */ |
||
310 | 1 | public function getInputService(Container $container) : Input |
|
314 | |||
315 | /** |
||
316 | * Get the InstallCommand class service |
||
317 | * |
||
318 | * @param Container $container The DI container. |
||
319 | * |
||
320 | * @return AppCommands\InstallCommand |
||
321 | */ |
||
322 | 1 | View Code Duplication | public function getInstallCommandService(Container $container) : AppCommands\InstallCommand |
331 | |||
332 | /** |
||
333 | * Get the router service |
||
334 | * |
||
335 | * @param Container $container The DI container. |
||
336 | * |
||
337 | * @return Router |
||
338 | */ |
||
339 | 1 | public function getRouterService(Container $container) : Router |
|
351 | |||
352 | /** |
||
353 | * Get the SnapshotCommand class service |
||
354 | * |
||
355 | * @param Container $container The DI container. |
||
356 | * |
||
357 | * @return AppCommands\SnapshotCommand |
||
358 | */ |
||
359 | 1 | View Code Duplication | public function getSnapshotCommandService(Container $container) : AppCommands\SnapshotCommand |
368 | |||
369 | /** |
||
370 | * Get the StatsJsonView class service |
||
371 | * |
||
372 | * @param Container $container The DI container. |
||
373 | * |
||
374 | * @return StatsJsonView |
||
375 | */ |
||
376 | 1 | public function getStatsJsonViewService(Container $container) : StatsJsonView |
|
382 | |||
383 | /** |
||
384 | * Get the StatsModel class service |
||
385 | * |
||
386 | * @param Container $container The DI container. |
||
387 | * |
||
388 | * @return StatsModel |
||
389 | */ |
||
390 | 1 | public function getStatsModelService(Container $container) : StatsModel |
|
396 | |||
397 | /** |
||
398 | * Get the SubmitControllerCreate class service |
||
399 | * |
||
400 | * @param Container $container The DI container. |
||
401 | * |
||
402 | * @return SubmitControllerCreate |
||
403 | */ |
||
404 | 1 | View Code Duplication | public function getSubmitControllerCreateService(Container $container) : SubmitControllerCreate |
415 | |||
416 | /** |
||
417 | * Get the SubmitControllerGet class service |
||
418 | * |
||
419 | * @param Container $container The DI container. |
||
420 | * |
||
421 | * @return SubmitControllerGet |
||
422 | */ |
||
423 | 1 | View Code Duplication | public function getSubmitControllerGetService(Container $container) : SubmitControllerGet |
432 | |||
433 | /** |
||
434 | * Get the Tags\JoomlaCommand class service |
||
435 | * |
||
436 | * @param Container $container The DI container. |
||
437 | * |
||
438 | * @return AppCommands\Tags\JoomlaCommand |
||
439 | */ |
||
440 | 1 | View Code Duplication | public function getTagsJoomlaCommandService(Container $container) : AppCommands\Tags\JoomlaCommand |
449 | |||
450 | /** |
||
451 | * Get the Tags\PhpCommand class service |
||
452 | * |
||
453 | * @param Container $container The DI container. |
||
454 | * |
||
455 | * @return AppCommands\Tags\PhpCommand |
||
456 | */ |
||
457 | 1 | View Code Duplication | public function getTagsPhpCommandService(Container $container) : AppCommands\Tags\PhpCommand |
466 | |||
467 | /** |
||
468 | * Get the UpdateCommand class service |
||
469 | * |
||
470 | * @param Container $container The DI container. |
||
471 | * |
||
472 | * @return AppCommands\UpdateCommand |
||
473 | */ |
||
474 | 1 | View Code Duplication | public function getUpdateCommandService(Container $container) : AppCommands\UpdateCommand |
483 | |||
484 | /** |
||
485 | * Get the web application service |
||
486 | * |
||
487 | * @param Container $container The DI container. |
||
488 | * |
||
489 | * @return WebApplication |
||
490 | */ |
||
491 | 1 | public function getWebApplicationService(Container $container) : WebApplication |
|
502 | } |
||
503 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.