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 EntitySetAnonymousType extends IsOK |
||
17 | { |
||
18 | use TSimpleIdentifierTrait, TUndottedIdentifierTrait, TQualifiedNameTrait, TSourceTypeTrait, TCommandTextTrait; |
||
19 | /** |
||
20 | * @property string $name |
||
21 | */ |
||
22 | private $name = null; |
||
23 | |||
24 | /** |
||
25 | * @property string $entityType |
||
26 | */ |
||
27 | private $entityType = null; |
||
28 | |||
29 | /** |
||
30 | * @property string $schema |
||
31 | */ |
||
32 | private $schema = null; |
||
33 | |||
34 | /** |
||
35 | * @property string $table |
||
36 | */ |
||
37 | private $table = null; |
||
38 | |||
39 | /** |
||
40 | * @property string $type |
||
41 | */ |
||
42 | private $type = null; |
||
43 | |||
44 | /** |
||
45 | * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TDocumentationType $documentation |
||
46 | */ |
||
47 | private $documentation = null; |
||
48 | |||
49 | /** |
||
50 | * @property string $definingQuery |
||
51 | */ |
||
52 | private $definingQuery = null; |
||
53 | |||
54 | /** |
||
55 | * Gets as name |
||
56 | * |
||
57 | * @return string |
||
58 | */ |
||
59 | public function getName() |
||
63 | |||
64 | /** |
||
65 | * Sets a new name |
||
66 | * |
||
67 | * @param string $name |
||
68 | * @return self |
||
69 | */ |
||
70 | public function setName($name) |
||
75 | |||
76 | /** |
||
77 | * Gets as entityType |
||
78 | * |
||
79 | * @return string |
||
80 | */ |
||
81 | public function getEntityType() |
||
85 | |||
86 | /** |
||
87 | * Sets a new entityType |
||
88 | * |
||
89 | * @param string $entityType |
||
90 | * @return self |
||
91 | */ |
||
92 | public function setEntityType($entityType) |
||
97 | |||
98 | /** |
||
99 | * Gets as schema |
||
100 | * |
||
101 | * @return string |
||
102 | */ |
||
103 | public function getSchema() |
||
107 | |||
108 | /** |
||
109 | * Sets a new schema |
||
110 | * |
||
111 | * @param string $schema |
||
112 | * @return self |
||
113 | */ |
||
114 | public function setSchema($schema) |
||
119 | |||
120 | /** |
||
121 | * Gets as table |
||
122 | * |
||
123 | * @return string |
||
124 | */ |
||
125 | public function getTable() |
||
129 | |||
130 | /** |
||
131 | * Sets a new table |
||
132 | * |
||
133 | * @param string $table |
||
134 | * @return self |
||
135 | */ |
||
136 | public function setTable($table) |
||
141 | |||
142 | /** |
||
143 | * Gets as type |
||
144 | * |
||
145 | * @return string |
||
146 | */ |
||
147 | public function getType() |
||
151 | |||
152 | /** |
||
153 | * Sets a new type |
||
154 | * |
||
155 | * @param string $type |
||
156 | * @return self |
||
157 | */ |
||
158 | public function setType($type) |
||
163 | |||
164 | /** |
||
165 | * Gets as documentation |
||
166 | * |
||
167 | * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TDocumentationType |
||
168 | */ |
||
169 | public function getDocumentation() |
||
173 | |||
174 | /** |
||
175 | * Sets a new documentation |
||
176 | * |
||
177 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TDocumentationType $documentation |
||
178 | * @return self |
||
179 | */ |
||
180 | public function setDocumentation(TDocumentationType $documentation) |
||
185 | |||
186 | /** |
||
187 | * Gets as definingQuery |
||
188 | * |
||
189 | * @return string |
||
190 | */ |
||
191 | public function getDefiningQuery() |
||
195 | |||
196 | /** |
||
197 | * Sets a new definingQuery |
||
198 | * |
||
199 | * @param string $definingQuery |
||
200 | * @return self |
||
201 | */ |
||
202 | public function setDefiningQuery($definingQuery) |
||
207 | |||
208 | public function isOK(&$msg = null) |
||
244 | } |
||
245 |
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.