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 |
||
13 | class EndAnonymousType extends IsOK |
||
14 | { |
||
15 | /** |
||
16 | * 1. The number of Ends has to match with ones defined in AssociationType |
||
17 | * 2. Value for attribute Name should match the defined ones and EntitySet should be of the |
||
18 | * defined Entity Type in AssociationType |
||
19 | */ |
||
20 | |||
21 | use GEmptyElementExtensibilityTrait, TSimpleIdentifierTrait; |
||
22 | |||
23 | /** |
||
24 | * @property string $role |
||
25 | */ |
||
26 | private $role = null; |
||
27 | |||
28 | /** |
||
29 | * @property string $entitySet |
||
30 | */ |
||
31 | private $entitySet = null; |
||
32 | |||
33 | /** |
||
34 | * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TDocumentationType $documentation |
||
35 | */ |
||
36 | private $documentation = null; |
||
37 | |||
38 | /** |
||
39 | * Gets as role |
||
40 | * |
||
41 | * @return string |
||
42 | */ |
||
43 | public function getRole() |
||
47 | |||
48 | /** |
||
49 | * Sets a new role |
||
50 | * |
||
51 | * @param string $role |
||
52 | * @return self |
||
53 | */ |
||
54 | public function setRole($role) |
||
59 | |||
60 | /** |
||
61 | * Gets as entitySet |
||
62 | * |
||
63 | * @return string |
||
64 | */ |
||
65 | public function getEntitySet() |
||
69 | |||
70 | /** |
||
71 | * Sets a new entitySet |
||
72 | * |
||
73 | * @param string $entitySet |
||
74 | * @return self |
||
75 | */ |
||
76 | public function setEntitySet($entitySet) |
||
81 | |||
82 | /** |
||
83 | * Gets as documentation |
||
84 | * |
||
85 | * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TDocumentationType |
||
86 | */ |
||
87 | public function getDocumentation() |
||
91 | |||
92 | /** |
||
93 | * Sets a new documentation |
||
94 | * |
||
95 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TDocumentationType $documentation |
||
96 | * @return self |
||
97 | */ |
||
98 | public function setDocumentation(TDocumentationType $documentation) |
||
103 | |||
104 | View Code Duplication | public function isOK(&$msg = null) |
|
127 | } |
||
128 |
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.