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 |
||
32 | class ApplicationServiceProvider implements ServiceProviderInterface |
||
33 | { |
||
34 | /** |
||
35 | * Registers the service provider with a DI container. |
||
36 | * |
||
37 | * @param Container $container The DI container. |
||
38 | * |
||
39 | * @return void |
||
40 | * |
||
41 | * @since 1.0 |
||
42 | */ |
||
43 | 1 | public function register(Container $container) |
|
99 | |||
100 | /** |
||
101 | * Get the Analytics class service |
||
102 | * |
||
103 | * @param Container $container The DI container. |
||
104 | * |
||
105 | * @return Analytics |
||
106 | * |
||
107 | * @since 1.0 |
||
108 | */ |
||
109 | 1 | public function getAnalyticsService(Container $container) |
|
113 | |||
114 | /** |
||
115 | * Get the Cache\ClearCommand class service |
||
116 | * |
||
117 | * @param Container $container The DI container. |
||
118 | * |
||
119 | * @return AppCommands\Cache\ClearCommand |
||
120 | * |
||
121 | * @since 1.0 |
||
122 | */ |
||
123 | 1 | View Code Duplication | public function getCacheClearCommandService(Container $container) : AppCommands\Cache\ClearCommand |
132 | |||
133 | /** |
||
134 | * Get the CLI application service |
||
135 | * |
||
136 | * @param Container $container The DI container. |
||
137 | * |
||
138 | * @return CliApplication |
||
139 | * |
||
140 | * @since 1.0 |
||
141 | */ |
||
142 | 1 | public function getCliApplicationService(Container $container) : CliApplication |
|
157 | |||
158 | /** |
||
159 | * Get the CliInput class service |
||
160 | * |
||
161 | * @param Container $container The DI container. |
||
162 | * |
||
163 | * @return JoomlaApplication\Cli\CliInput |
||
164 | * |
||
165 | * @since 1.0 |
||
166 | */ |
||
167 | 1 | public function getCliInputService(Container $container) : JoomlaApplication\Cli\CliInput |
|
171 | |||
172 | /** |
||
173 | * Get the CliOutput class service |
||
174 | * |
||
175 | * @param Container $container The DI container. |
||
176 | * |
||
177 | * @return JoomlaApplication\Cli\CliOutput |
||
178 | * |
||
179 | * @since 1.0 |
||
180 | */ |
||
181 | 1 | public function getCliOutputService(Container $container) : JoomlaApplication\Cli\Output\Stdout |
|
185 | |||
186 | /** |
||
187 | * Get the ColorProcessor class service |
||
188 | * |
||
189 | * @param Container $container The DI container. |
||
190 | * |
||
191 | * @return JoomlaApplication\Cli\Output\Processor\ColorProcessor |
||
192 | * |
||
193 | * @since 1.0 |
||
194 | */ |
||
195 | 1 | public function getColorProcessorService(Container $container) : JoomlaApplication\Cli\Output\Processor\ColorProcessor |
|
212 | |||
213 | /** |
||
214 | * Get the console service |
||
215 | * |
||
216 | * @param Container $container The DI container. |
||
217 | * |
||
218 | * @return Console |
||
219 | * |
||
220 | * @since 1.0 |
||
221 | */ |
||
222 | 1 | public function getConsoleService(Container $container) : Console |
|
229 | |||
230 | /** |
||
231 | * Get the Database\MigrateCommand class service |
||
232 | * |
||
233 | * @param Container $container The DI container. |
||
234 | * |
||
235 | * @return AppCommands\Database\MigrateCommand |
||
236 | * |
||
237 | * @since 1.0 |
||
238 | */ |
||
239 | 1 | public function getDatabaseMigrateCommandService(Container $container) : AppCommands\Database\MigrateCommand |
|
249 | |||
250 | /** |
||
251 | * Get the Database\StatusCommand class service |
||
252 | * |
||
253 | * @param Container $container The DI container. |
||
254 | * |
||
255 | * @return AppCommands\Database\StatusCommand |
||
256 | * |
||
257 | * @since 1.0 |
||
258 | */ |
||
259 | 1 | View Code Duplication | public function getDatabaseStatusCommandService(Container $container) : AppCommands\Database\StatusCommand |
268 | |||
269 | /** |
||
270 | * Get the DisplayControllerGet class service |
||
271 | * |
||
272 | * @param Container $container The DI container. |
||
273 | * |
||
274 | * @return DisplayControllerGet |
||
275 | * |
||
276 | * @since 1.0 |
||
277 | */ |
||
278 | 1 | View Code Duplication | public function getDisplayControllerGetService(Container $container) : DisplayControllerGet |
290 | |||
291 | /** |
||
292 | * Get the HelpCommand class service |
||
293 | * |
||
294 | * @param Container $container The DI container. |
||
295 | * |
||
296 | * @return AppCommands\HelpCommand |
||
297 | * |
||
298 | * @since 1.0 |
||
299 | */ |
||
300 | 1 | View Code Duplication | public function getHelpCommandService(Container $container) : AppCommands\HelpCommand |
309 | |||
310 | /** |
||
311 | * Get the Input\Cli class service |
||
312 | * |
||
313 | * @param Container $container The DI container. |
||
314 | * |
||
315 | * @return Cli |
||
316 | * |
||
317 | * @since 1.0 |
||
318 | */ |
||
319 | 1 | public function getInputCliService(Container $container) : Cli |
|
323 | |||
324 | /** |
||
325 | * Get the Input class service |
||
326 | * |
||
327 | * @param Container $container The DI container. |
||
328 | * |
||
329 | * @return Input |
||
330 | * |
||
331 | * @since 1.0 |
||
332 | */ |
||
333 | 1 | public function getInputService(Container $container) : Input |
|
337 | |||
338 | /** |
||
339 | * Get the InstallCommand class service |
||
340 | * |
||
341 | * @param Container $container The DI container. |
||
342 | * |
||
343 | * @return AppCommands\InstallCommand |
||
344 | * |
||
345 | * @since 1.0 |
||
346 | */ |
||
347 | 1 | View Code Duplication | public function getInstallCommandService(Container $container) : AppCommands\InstallCommand |
356 | |||
357 | /** |
||
358 | * Get the router service |
||
359 | * |
||
360 | * @param Container $container The DI container. |
||
361 | * |
||
362 | * @return Router |
||
363 | * |
||
364 | * @since 1.0 |
||
365 | */ |
||
366 | 1 | public function getRouterService(Container $container) : Router |
|
378 | |||
379 | /** |
||
380 | * Get the SnapshotCommand class service |
||
381 | * |
||
382 | * @param Container $container The DI container. |
||
383 | * |
||
384 | * @return AppCommands\SnapshotCommand |
||
385 | * |
||
386 | * @since 1.0 |
||
387 | */ |
||
388 | 1 | View Code Duplication | public function getSnapshotCommandService(Container $container) : AppCommands\SnapshotCommand |
397 | |||
398 | /** |
||
399 | * Get the StatsJsonView class service |
||
400 | * |
||
401 | * @param Container $container The DI container. |
||
402 | * |
||
403 | * @return StatsJsonView |
||
404 | * |
||
405 | * @since 1.0 |
||
406 | */ |
||
407 | 1 | public function getStatsJsonViewService(Container $container) : StatsJsonView |
|
413 | |||
414 | /** |
||
415 | * Get the StatsModel class service |
||
416 | * |
||
417 | * @param Container $container The DI container. |
||
418 | * |
||
419 | * @return StatsModel |
||
420 | * |
||
421 | * @since 1.0 |
||
422 | */ |
||
423 | 1 | public function getStatsModelService(Container $container) : StatsModel |
|
429 | |||
430 | /** |
||
431 | * Get the SubmitControllerCreate class service |
||
432 | * |
||
433 | * @param Container $container The DI container. |
||
434 | * |
||
435 | * @return SubmitControllerCreate |
||
436 | * |
||
437 | * @since 1.0 |
||
438 | */ |
||
439 | 1 | View Code Duplication | public function getSubmitControllerCreateService(Container $container) : SubmitControllerCreate |
450 | |||
451 | /** |
||
452 | * Get the SubmitControllerGet class service |
||
453 | * |
||
454 | * @param Container $container The DI container. |
||
455 | * |
||
456 | * @return SubmitControllerGet |
||
457 | * |
||
458 | * @since 1.0 |
||
459 | */ |
||
460 | 1 | View Code Duplication | public function getSubmitControllerGetService(Container $container) : SubmitControllerGet |
469 | |||
470 | /** |
||
471 | * Get the Tags\JoomlaCommand class service |
||
472 | * |
||
473 | * @param Container $container The DI container. |
||
474 | * |
||
475 | * @return AppCommands\Tags\JoomlaCommand |
||
476 | * |
||
477 | * @since 1.0 |
||
478 | */ |
||
479 | 1 | View Code Duplication | public function getTagsJoomlaCommandService(Container $container) : AppCommands\Tags\JoomlaCommand |
488 | |||
489 | /** |
||
490 | * Get the Tags\PhpCommand class service |
||
491 | * |
||
492 | * @param Container $container The DI container. |
||
493 | * |
||
494 | * @return AppCommands\Tags\PhpCommand |
||
495 | * |
||
496 | * @since 1.0 |
||
497 | */ |
||
498 | 1 | View Code Duplication | public function getTagsPhpCommandService(Container $container) : AppCommands\Tags\PhpCommand |
507 | |||
508 | /** |
||
509 | * Get the UpdateCommand class service |
||
510 | * |
||
511 | * @param Container $container The DI container. |
||
512 | * |
||
513 | * @return AppCommands\UpdateCommand |
||
514 | * |
||
515 | * @since 1.0 |
||
516 | */ |
||
517 | 1 | View Code Duplication | public function getUpdateCommandService(Container $container) : AppCommands\UpdateCommand |
526 | |||
527 | /** |
||
528 | * Get the web application service |
||
529 | * |
||
530 | * @param Container $container The DI container. |
||
531 | * |
||
532 | * @return WebApplication |
||
533 | * |
||
534 | * @since 1.0 |
||
535 | */ |
||
536 | 1 | public function getWebApplicationService(Container $container) : WebApplication |
|
547 | } |
||
548 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.