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 |
||
14 | class TReferentialConstraintRoleElementType extends IsOK |
||
15 | { |
||
16 | use TSimpleIdentifierTrait; |
||
17 | /** |
||
18 | * @property string $role |
||
19 | */ |
||
20 | private $role = null; |
||
21 | |||
22 | /** |
||
23 | * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TDocumentationType $documentation |
||
24 | */ |
||
25 | private $documentation = null; |
||
26 | |||
27 | /** |
||
28 | * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TPropertyRefType[] $propertyRef |
||
29 | */ |
||
30 | private $propertyRef = []; |
||
31 | |||
32 | /** |
||
33 | * Gets as role |
||
34 | * |
||
35 | * @return string |
||
36 | */ |
||
37 | public function getRole() |
||
41 | |||
42 | /** |
||
43 | * Sets a new role |
||
44 | * |
||
45 | * @param string $role |
||
46 | * @return self |
||
47 | */ |
||
48 | public function setRole($role) |
||
53 | |||
54 | /** |
||
55 | * Gets as documentation |
||
56 | * |
||
57 | * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TDocumentationType |
||
58 | */ |
||
59 | public function getDocumentation() |
||
63 | |||
64 | /** |
||
65 | * Sets a new documentation |
||
66 | * |
||
67 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TDocumentationType $documentation |
||
68 | * @return self |
||
69 | */ |
||
70 | public function setDocumentation(TDocumentationType $documentation) |
||
75 | |||
76 | /** |
||
77 | * Adds as propertyRef |
||
78 | * |
||
79 | * @return self |
||
80 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TPropertyRefType $propertyRef |
||
81 | */ |
||
82 | public function addToPropertyRef(TPropertyRefType $propertyRef) |
||
87 | |||
88 | /** |
||
89 | * isset propertyRef |
||
90 | * |
||
91 | * @param scalar $index |
||
92 | * @return boolean |
||
93 | */ |
||
94 | public function issetPropertyRef($index) |
||
98 | |||
99 | /** |
||
100 | * unset propertyRef |
||
101 | * |
||
102 | * @param scalar $index |
||
103 | * @return void |
||
104 | */ |
||
105 | public function unsetPropertyRef($index) |
||
109 | |||
110 | /** |
||
111 | * Gets as propertyRef |
||
112 | * |
||
113 | * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TPropertyRefType[] |
||
114 | */ |
||
115 | public function getPropertyRef() |
||
119 | |||
120 | /** |
||
121 | * Sets a new propertyRef |
||
122 | * |
||
123 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TPropertyRefType[] $propertyRef |
||
124 | * @return self |
||
125 | */ |
||
126 | public function setPropertyRef(array $propertyRef) |
||
131 | |||
132 | View Code Duplication | public function isOK(&$msg = null) |
|
155 | } |
||
156 |
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.