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 |
||
| 39 | class ApplicationServiceProvider implements ServiceProviderInterface |
||
| 40 | { |
||
| 41 | /** |
||
| 42 | * Registers the service provider with a DI container. |
||
| 43 | * |
||
| 44 | * @param Container $container The DI container. |
||
| 45 | * |
||
| 46 | * @return void |
||
| 47 | * |
||
| 48 | * @since 1.0 |
||
| 49 | */ |
||
| 50 | 1 | public function register(Container $container) |
|
| 106 | |||
| 107 | /** |
||
| 108 | * Get the Analytics class service |
||
| 109 | * |
||
| 110 | * @param Container $container The DI container. |
||
| 111 | * |
||
| 112 | * @return Analytics |
||
| 113 | * |
||
| 114 | * @since 1.0 |
||
| 115 | */ |
||
| 116 | 1 | public function getAnalyticsService(Container $container) |
|
| 120 | |||
| 121 | /** |
||
| 122 | * Get the Cache\ClearCommand class service |
||
| 123 | * |
||
| 124 | * @param Container $container The DI container. |
||
| 125 | * |
||
| 126 | * @return AppCommands\Cache\ClearCommand |
||
| 127 | * |
||
| 128 | * @since 1.0 |
||
| 129 | */ |
||
| 130 | 1 | View Code Duplication | public function getCacheClearCommandService(Container $container) : AppCommands\Cache\ClearCommand |
| 139 | |||
| 140 | /** |
||
| 141 | * Get the CLI application service |
||
| 142 | * |
||
| 143 | * @param Container $container The DI container. |
||
| 144 | * |
||
| 145 | * @return CliApplication |
||
| 146 | * |
||
| 147 | * @since 1.0 |
||
| 148 | */ |
||
| 149 | 1 | public function getCliApplicationService(Container $container) : CliApplication |
|
| 164 | |||
| 165 | /** |
||
| 166 | * Get the CliInput class service |
||
| 167 | * |
||
| 168 | * @param Container $container The DI container. |
||
| 169 | * |
||
| 170 | * @return JoomlaApplication\Cli\CliInput |
||
| 171 | * |
||
| 172 | * @since 1.0 |
||
| 173 | */ |
||
| 174 | 1 | public function getCliInputService(Container $container) : JoomlaApplication\Cli\CliInput |
|
| 178 | |||
| 179 | /** |
||
| 180 | * Get the CliOutput class service |
||
| 181 | * |
||
| 182 | * @param Container $container The DI container. |
||
| 183 | * |
||
| 184 | * @return JoomlaApplication\Cli\CliOutput |
||
| 185 | * |
||
| 186 | * @since 1.0 |
||
| 187 | */ |
||
| 188 | 1 | public function getCliOutputService(Container $container) : JoomlaApplication\Cli\Output\Stdout |
|
| 192 | |||
| 193 | /** |
||
| 194 | * Get the ColorProcessor class service |
||
| 195 | * |
||
| 196 | * @param Container $container The DI container. |
||
| 197 | * |
||
| 198 | * @return JoomlaApplication\Cli\Output\Processor\ColorProcessor |
||
| 199 | * |
||
| 200 | * @since 1.0 |
||
| 201 | */ |
||
| 202 | 1 | public function getColorProcessorService(Container $container) : JoomlaApplication\Cli\Output\Processor\ColorProcessor |
|
| 219 | |||
| 220 | /** |
||
| 221 | * Get the console service |
||
| 222 | * |
||
| 223 | * @param Container $container The DI container. |
||
| 224 | * |
||
| 225 | * @return Console |
||
| 226 | * |
||
| 227 | * @since 1.0 |
||
| 228 | */ |
||
| 229 | 1 | public function getConsoleService(Container $container) : Console |
|
| 236 | |||
| 237 | /** |
||
| 238 | * Get the Database\MigrateCommand class service |
||
| 239 | * |
||
| 240 | * @param Container $container The DI container. |
||
| 241 | * |
||
| 242 | * @return AppCommands\Database\MigrateCommand |
||
| 243 | * |
||
| 244 | * @since 1.0 |
||
| 245 | */ |
||
| 246 | 1 | public function getDatabaseMigrateCommandService(Container $container) : AppCommands\Database\MigrateCommand |
|
| 256 | |||
| 257 | /** |
||
| 258 | * Get the Database\StatusCommand class service |
||
| 259 | * |
||
| 260 | * @param Container $container The DI container. |
||
| 261 | * |
||
| 262 | * @return AppCommands\Database\StatusCommand |
||
| 263 | * |
||
| 264 | * @since 1.0 |
||
| 265 | */ |
||
| 266 | 1 | View Code Duplication | public function getDatabaseStatusCommandService(Container $container) : AppCommands\Database\StatusCommand |
| 275 | |||
| 276 | /** |
||
| 277 | * Get the DisplayControllerGet class service |
||
| 278 | * |
||
| 279 | * @param Container $container The DI container. |
||
| 280 | * |
||
| 281 | * @return DisplayControllerGet |
||
| 282 | * |
||
| 283 | * @since 1.0 |
||
| 284 | */ |
||
| 285 | 1 | View Code Duplication | public function getDisplayControllerGetService(Container $container) : DisplayControllerGet |
| 297 | |||
| 298 | /** |
||
| 299 | * Get the HelpCommand class service |
||
| 300 | * |
||
| 301 | * @param Container $container The DI container. |
||
| 302 | * |
||
| 303 | * @return AppCommands\HelpCommand |
||
| 304 | * |
||
| 305 | * @since 1.0 |
||
| 306 | */ |
||
| 307 | 1 | View Code Duplication | public function getHelpCommandService(Container $container) : AppCommands\HelpCommand |
| 316 | |||
| 317 | /** |
||
| 318 | * Get the Input\Cli class service |
||
| 319 | * |
||
| 320 | * @param Container $container The DI container. |
||
| 321 | * |
||
| 322 | * @return Cli |
||
| 323 | * |
||
| 324 | * @since 1.0 |
||
| 325 | */ |
||
| 326 | 1 | public function getInputCliService(Container $container) : Cli |
|
| 330 | |||
| 331 | /** |
||
| 332 | * Get the Input class service |
||
| 333 | * |
||
| 334 | * @param Container $container The DI container. |
||
| 335 | * |
||
| 336 | * @return Input |
||
| 337 | * |
||
| 338 | * @since 1.0 |
||
| 339 | */ |
||
| 340 | 1 | public function getInputService(Container $container) : Input |
|
| 344 | |||
| 345 | /** |
||
| 346 | * Get the InstallCommand class service |
||
| 347 | * |
||
| 348 | * @param Container $container The DI container. |
||
| 349 | * |
||
| 350 | * @return AppCommands\InstallCommand |
||
| 351 | * |
||
| 352 | * @since 1.0 |
||
| 353 | */ |
||
| 354 | 1 | View Code Duplication | public function getInstallCommandService(Container $container) : AppCommands\InstallCommand |
| 363 | |||
| 364 | /** |
||
| 365 | * Get the router service |
||
| 366 | * |
||
| 367 | * @param Container $container The DI container. |
||
| 368 | * |
||
| 369 | * @return Router |
||
| 370 | * |
||
| 371 | * @since 1.0 |
||
| 372 | */ |
||
| 373 | 1 | public function getRouterService(Container $container) : Router |
|
| 385 | |||
| 386 | /** |
||
| 387 | * Get the SnapshotCommand class service |
||
| 388 | * |
||
| 389 | * @param Container $container The DI container. |
||
| 390 | * |
||
| 391 | * @return AppCommands\SnapshotCommand |
||
| 392 | * |
||
| 393 | * @since 1.0 |
||
| 394 | */ |
||
| 395 | 1 | View Code Duplication | public function getSnapshotCommandService(Container $container) : AppCommands\SnapshotCommand |
| 404 | |||
| 405 | /** |
||
| 406 | * Get the StatsJsonView class service |
||
| 407 | * |
||
| 408 | * @param Container $container The DI container. |
||
| 409 | * |
||
| 410 | * @return StatsJsonView |
||
| 411 | * |
||
| 412 | * @since 1.0 |
||
| 413 | */ |
||
| 414 | 1 | public function getStatsJsonViewService(Container $container) : StatsJsonView |
|
| 420 | |||
| 421 | /** |
||
| 422 | * Get the StatsModel class service |
||
| 423 | * |
||
| 424 | * @param Container $container The DI container. |
||
| 425 | * |
||
| 426 | * @return StatsModel |
||
| 427 | * |
||
| 428 | * @since 1.0 |
||
| 429 | */ |
||
| 430 | 1 | public function getStatsModelService(Container $container) : StatsModel |
|
| 436 | |||
| 437 | /** |
||
| 438 | * Get the SubmitControllerCreate class service |
||
| 439 | * |
||
| 440 | * @param Container $container The DI container. |
||
| 441 | * |
||
| 442 | * @return SubmitControllerCreate |
||
| 443 | * |
||
| 444 | * @since 1.0 |
||
| 445 | */ |
||
| 446 | 1 | View Code Duplication | public function getSubmitControllerCreateService(Container $container) : SubmitControllerCreate |
| 457 | |||
| 458 | /** |
||
| 459 | * Get the SubmitControllerGet class service |
||
| 460 | * |
||
| 461 | * @param Container $container The DI container. |
||
| 462 | * |
||
| 463 | * @return SubmitControllerGet |
||
| 464 | * |
||
| 465 | * @since 1.0 |
||
| 466 | */ |
||
| 467 | 1 | View Code Duplication | public function getSubmitControllerGetService(Container $container) : SubmitControllerGet |
| 476 | |||
| 477 | /** |
||
| 478 | * Get the Tags\JoomlaCommand class service |
||
| 479 | * |
||
| 480 | * @param Container $container The DI container. |
||
| 481 | * |
||
| 482 | * @return AppCommands\Tags\JoomlaCommand |
||
| 483 | * |
||
| 484 | * @since 1.0 |
||
| 485 | */ |
||
| 486 | 1 | View Code Duplication | public function getTagsJoomlaCommandService(Container $container) : AppCommands\Tags\JoomlaCommand |
| 495 | |||
| 496 | /** |
||
| 497 | * Get the Tags\PhpCommand class service |
||
| 498 | * |
||
| 499 | * @param Container $container The DI container. |
||
| 500 | * |
||
| 501 | * @return AppCommands\Tags\PhpCommand |
||
| 502 | * |
||
| 503 | * @since 1.0 |
||
| 504 | */ |
||
| 505 | 1 | View Code Duplication | public function getTagsPhpCommandService(Container $container) : AppCommands\Tags\PhpCommand |
| 514 | |||
| 515 | /** |
||
| 516 | * Get the UpdateCommand class service |
||
| 517 | * |
||
| 518 | * @param Container $container The DI container. |
||
| 519 | * |
||
| 520 | * @return AppCommands\UpdateCommand |
||
| 521 | * |
||
| 522 | * @since 1.0 |
||
| 523 | */ |
||
| 524 | 1 | View Code Duplication | public function getUpdateCommandService(Container $container) : AppCommands\UpdateCommand |
| 533 | |||
| 534 | /** |
||
| 535 | * Get the web application service |
||
| 536 | * |
||
| 537 | * @param Container $container The DI container. |
||
| 538 | * |
||
| 539 | * @return WebApplication |
||
| 540 | * |
||
| 541 | * @since 1.0 |
||
| 542 | */ |
||
| 543 | 1 | public function getWebApplicationService(Container $container) : WebApplication |
|
| 554 | } |
||
| 555 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.