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 |
||
| 16 | class Projector implements EventListenerInterface |
||
| 17 | { |
||
| 18 | use DelegateEventHandlingToSpecificMethodTrait; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @var RepositoryInterface |
||
| 22 | */ |
||
| 23 | private $repository; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @var SapiVersion |
||
| 27 | */ |
||
| 28 | private $sapiVersion; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * @param RepositoryInterface $repository |
||
| 32 | * @param SapiVersion $sapiVersion |
||
| 33 | */ |
||
| 34 | public function __construct( |
||
| 41 | |||
| 42 | /** |
||
| 43 | * @param RoleCreated $roleCreated |
||
| 44 | * @param DomainMessage $domainMessage |
||
| 45 | */ |
||
| 46 | public function applyRoleCreated( |
||
| 55 | |||
| 56 | /** |
||
| 57 | * @param RoleRenamed $roleRenamed |
||
| 58 | * @param DomainMessage $domainMessage |
||
| 59 | */ |
||
| 60 | public function applyRoleRenamed( |
||
| 69 | |||
| 70 | /** |
||
| 71 | * @param RoleDeleted $roleDeleted |
||
| 72 | * @param DomainMessage $domainMessage |
||
| 73 | */ |
||
| 74 | public function applyRoleDeleted( |
||
| 80 | |||
| 81 | /** |
||
| 82 | * @param ConstraintAdded $constraintAdded |
||
| 83 | */ |
||
| 84 | View Code Duplication | protected function applyConstraintAdded(ConstraintAdded $constraintAdded) |
|
| 94 | |||
| 95 | /** |
||
| 96 | * @param ConstraintUpdated $constraintUpdated |
||
| 97 | */ |
||
| 98 | View Code Duplication | protected function applyConstraintUpdated(ConstraintUpdated $constraintUpdated) |
|
| 108 | |||
| 109 | /** |
||
| 110 | * @param ConstraintRemoved $constraintRemoved |
||
| 111 | */ |
||
| 112 | protected function applyConstraintRemoved(ConstraintRemoved $constraintRemoved) |
||
| 121 | } |
||
| 122 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.