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 |
||
29 | View Code Duplication | class IdentityAccreditedAsRaaForInstitutionEvent extends IdentityEvent |
|
|
|||
30 | { |
||
31 | /** |
||
32 | * @var NameId |
||
33 | */ |
||
34 | public $nameId; |
||
35 | |||
36 | /** |
||
37 | * @var RegistrationAuthorityRole |
||
38 | */ |
||
39 | public $registrationAuthorityRole; |
||
40 | |||
41 | /** |
||
42 | * @var Location |
||
43 | */ |
||
44 | public $location; |
||
45 | |||
46 | /** |
||
47 | * @var ContactInformation |
||
48 | */ |
||
49 | public $contactInformation; |
||
50 | /** |
||
51 | * @var Institution |
||
52 | */ |
||
53 | public $raInstitution; |
||
54 | |||
55 | /** |
||
56 | * @param IdentityId $identityId |
||
57 | * @param NameId $nameId |
||
58 | * @param Institution $institution |
||
59 | * @param RegistrationAuthorityRole $role |
||
60 | * @param Location $location |
||
61 | * @param ContactInformation $contactInformation |
||
62 | * @param Institution $raInstitution |
||
63 | */ |
||
64 | public function __construct( |
||
81 | |||
82 | public function getAuditLogMetadata() |
||
90 | |||
91 | public static function deserialize(array $data) |
||
103 | |||
104 | public function serialize() |
||
116 | } |
||
117 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.