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 |
||
| 36 | class ApplicationServiceProvider implements ServiceProviderInterface |
||
| 37 | { |
||
| 38 | /** |
||
| 39 | * Registers the service provider with a DI container. |
||
| 40 | * |
||
| 41 | * @param Container $container The DI container. |
||
| 42 | * |
||
| 43 | * @return void |
||
| 44 | */ |
||
| 45 | 1 | public function register(Container $container) |
|
| 101 | |||
| 102 | /** |
||
| 103 | * Get the Analytics class service |
||
| 104 | * |
||
| 105 | * @param Container $container The DI container. |
||
| 106 | * |
||
| 107 | * @return Analytics |
||
| 108 | */ |
||
| 109 | 1 | public function getAnalyticsService(Container $container) |
|
| 113 | |||
| 114 | /** |
||
| 115 | * Get the CLI application service |
||
| 116 | * |
||
| 117 | * @param Container $container The DI container. |
||
| 118 | * |
||
| 119 | * @return CliApplication |
||
| 120 | */ |
||
| 121 | 1 | public function getCliApplicationService(Container $container) : CliApplication |
|
| 136 | |||
| 137 | /** |
||
| 138 | * Get the CliInput class service |
||
| 139 | * |
||
| 140 | * @param Container $container The DI container. |
||
| 141 | * |
||
| 142 | * @return JoomlaApplication\Cli\CliInput |
||
| 143 | */ |
||
| 144 | 1 | public function getCliInputService(Container $container) : JoomlaApplication\Cli\CliInput |
|
| 148 | |||
| 149 | /** |
||
| 150 | * Get the CliOutput class service |
||
| 151 | * |
||
| 152 | * @param Container $container The DI container. |
||
| 153 | * |
||
| 154 | * @return JoomlaApplication\Cli\CliOutput |
||
| 155 | */ |
||
| 156 | 1 | public function getCliOutputService(Container $container) : JoomlaApplication\Cli\Output\Stdout |
|
| 160 | |||
| 161 | /** |
||
| 162 | * Get the ColorProcessor class service |
||
| 163 | * |
||
| 164 | * @param Container $container The DI container. |
||
| 165 | * |
||
| 166 | * @return JoomlaApplication\Cli\Output\Processor\ColorProcessor |
||
| 167 | */ |
||
| 168 | 1 | public function getColorProcessorService(Container $container) : JoomlaApplication\Cli\Output\Processor\ColorProcessor |
|
| 185 | |||
| 186 | /** |
||
| 187 | * Get the console service |
||
| 188 | * |
||
| 189 | * @param Container $container The DI container. |
||
| 190 | * |
||
| 191 | * @return Console |
||
| 192 | */ |
||
| 193 | 1 | public function getConsoleService(Container $container) : Console |
|
| 200 | |||
| 201 | /** |
||
| 202 | * Get the Database\MigrateCommand class service |
||
| 203 | * |
||
| 204 | * @param Container $container The DI container. |
||
| 205 | * |
||
| 206 | * @return AppCommands\Database\MigrateCommand |
||
| 207 | */ |
||
| 208 | 1 | public function getDatabaseMigrateCommandService(Container $container) : AppCommands\Database\MigrateCommand |
|
| 218 | |||
| 219 | /** |
||
| 220 | * Get the Database\StatusCommand class service |
||
| 221 | * |
||
| 222 | * @param Container $container The DI container. |
||
| 223 | * |
||
| 224 | * @return AppCommands\Database\StatusCommand |
||
| 225 | */ |
||
| 226 | 1 | View Code Duplication | public function getDatabaseStatusCommandService(Container $container) : AppCommands\Database\StatusCommand |
| 235 | |||
| 236 | /** |
||
| 237 | * Get the DisplayControllerCreate class service |
||
| 238 | * |
||
| 239 | * @param Container $container The DI container. |
||
| 240 | * |
||
| 241 | * @return DisplayControllerCreate |
||
| 242 | */ |
||
| 243 | View Code Duplication | public function getDisplayControllerCreateService(Container $container) : DisplayControllerCreate |
|
| 252 | |||
| 253 | /** |
||
| 254 | * Get the DisplayControllerGet class service |
||
| 255 | * |
||
| 256 | * @param Container $container The DI container. |
||
| 257 | * |
||
| 258 | * @return DisplayControllerGet |
||
| 259 | */ |
||
| 260 | 1 | View Code Duplication | public function getDisplayControllerGetService(Container $container) : DisplayControllerGet |
| 271 | |||
| 272 | /** |
||
| 273 | * Get the HelpCommand class service |
||
| 274 | * |
||
| 275 | * @param Container $container The DI container. |
||
| 276 | * |
||
| 277 | * @return AppCommands\HelpCommand |
||
| 278 | */ |
||
| 279 | 1 | View Code Duplication | public function getHelpCommandService(Container $container) : AppCommands\HelpCommand |
| 288 | |||
| 289 | /** |
||
| 290 | * Get the Input\Cli class service |
||
| 291 | * |
||
| 292 | * @param Container $container The DI container. |
||
| 293 | * |
||
| 294 | * @return Cli |
||
| 295 | */ |
||
| 296 | 1 | public function getInputCliService(Container $container) : Cli |
|
| 300 | |||
| 301 | /** |
||
| 302 | * Get the Input class service |
||
| 303 | * |
||
| 304 | * @param Container $container The DI container. |
||
| 305 | * |
||
| 306 | * @return Input |
||
| 307 | */ |
||
| 308 | 1 | public function getInputService(Container $container) : Input |
|
| 312 | |||
| 313 | /** |
||
| 314 | * Get the InstallCommand class service |
||
| 315 | * |
||
| 316 | * @param Container $container The DI container. |
||
| 317 | * |
||
| 318 | * @return AppCommands\InstallCommand |
||
| 319 | */ |
||
| 320 | 1 | View Code Duplication | public function getInstallCommandService(Container $container) : AppCommands\InstallCommand |
| 329 | |||
| 330 | /** |
||
| 331 | * Get the router service |
||
| 332 | * |
||
| 333 | * @param Container $container The DI container. |
||
| 334 | * |
||
| 335 | * @return Router |
||
| 336 | */ |
||
| 337 | 1 | public function getRouterService(Container $container) : Router |
|
| 349 | |||
| 350 | /** |
||
| 351 | * Get the SnapshotCommand class service |
||
| 352 | * |
||
| 353 | * @param Container $container The DI container. |
||
| 354 | * |
||
| 355 | * @return AppCommands\SnapshotCommand |
||
| 356 | */ |
||
| 357 | 1 | View Code Duplication | public function getSnapshotCommandService(Container $container) : AppCommands\SnapshotCommand |
| 366 | |||
| 367 | /** |
||
| 368 | * Get the StatsJsonView class service |
||
| 369 | * |
||
| 370 | * @param Container $container The DI container. |
||
| 371 | * |
||
| 372 | * @return StatsJsonView |
||
| 373 | */ |
||
| 374 | 1 | public function getStatsJsonViewService(Container $container) : StatsJsonView |
|
| 380 | |||
| 381 | /** |
||
| 382 | * Get the StatsModel class service |
||
| 383 | * |
||
| 384 | * @param Container $container The DI container. |
||
| 385 | * |
||
| 386 | * @return StatsModel |
||
| 387 | */ |
||
| 388 | 1 | public function getStatsModelService(Container $container) : StatsModel |
|
| 394 | |||
| 395 | /** |
||
| 396 | * Get the SubmitControllerCreate class service |
||
| 397 | * |
||
| 398 | * @param Container $container The DI container. |
||
| 399 | * |
||
| 400 | * @return SubmitControllerCreate |
||
| 401 | */ |
||
| 402 | 1 | View Code Duplication | public function getSubmitControllerCreateService(Container $container) : SubmitControllerCreate |
| 413 | |||
| 414 | /** |
||
| 415 | * Get the SubmitControllerGet class service |
||
| 416 | * |
||
| 417 | * @param Container $container The DI container. |
||
| 418 | * |
||
| 419 | * @return SubmitControllerGet |
||
| 420 | */ |
||
| 421 | 1 | View Code Duplication | public function getSubmitControllerGetService(Container $container) : SubmitControllerGet |
| 430 | |||
| 431 | /** |
||
| 432 | * Get the Tags\JoomlaCommand class service |
||
| 433 | * |
||
| 434 | * @param Container $container The DI container. |
||
| 435 | * |
||
| 436 | * @return AppCommands\Tags\JoomlaCommand |
||
| 437 | */ |
||
| 438 | 1 | View Code Duplication | public function getTagsJoomlaCommandService(Container $container) : AppCommands\Tags\JoomlaCommand |
| 447 | |||
| 448 | /** |
||
| 449 | * Get the Tags\PhpCommand class service |
||
| 450 | * |
||
| 451 | * @param Container $container The DI container. |
||
| 452 | * |
||
| 453 | * @return AppCommands\Tags\PhpCommand |
||
| 454 | */ |
||
| 455 | 1 | View Code Duplication | public function getTagsPhpCommandService(Container $container) : AppCommands\Tags\PhpCommand |
| 464 | |||
| 465 | /** |
||
| 466 | * Get the UpdateCommand class service |
||
| 467 | * |
||
| 468 | * @param Container $container The DI container. |
||
| 469 | * |
||
| 470 | * @return AppCommands\UpdateCommand |
||
| 471 | */ |
||
| 472 | 1 | View Code Duplication | public function getUpdateCommandService(Container $container) : AppCommands\UpdateCommand |
| 481 | |||
| 482 | /** |
||
| 483 | * Get the web application service |
||
| 484 | * |
||
| 485 | * @param Container $container The DI container. |
||
| 486 | * |
||
| 487 | * @return WebApplication |
||
| 488 | */ |
||
| 489 | 1 | public function getWebApplicationService(Container $container) : WebApplication |
|
| 500 | } |
||
| 501 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.