Complex classes like TSchemaType often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use TSchemaType, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
15 | class TSchemaType extends IsOK |
||
16 | { |
||
17 | use TQualifiedNameTrait, TSimpleIdentifierTrait; |
||
18 | /** |
||
19 | * @property string $namespace |
||
20 | */ |
||
21 | private $namespace = null; |
||
22 | |||
23 | /** |
||
24 | * @property string $alias |
||
25 | */ |
||
26 | private $alias = null; |
||
27 | |||
28 | /** |
||
29 | * @property string $provider |
||
30 | */ |
||
31 | private $provider = null; |
||
32 | |||
33 | /** |
||
34 | * @property string $providerManifestToken |
||
35 | */ |
||
36 | private $providerManifestToken = null; |
||
37 | |||
38 | /** |
||
39 | * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TAssociationType[] $association |
||
40 | */ |
||
41 | private $association = []; |
||
42 | |||
43 | /** |
||
44 | * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TEntityTypeType[] $entityType |
||
45 | */ |
||
46 | private $entityType = []; |
||
47 | |||
48 | /** |
||
49 | * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\EntityContainer[] $entityContainer |
||
50 | */ |
||
51 | private $entityContainer = []; |
||
52 | |||
53 | /** |
||
54 | * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TFunctionType[] $function |
||
55 | */ |
||
56 | private $function = []; |
||
57 | |||
58 | /** |
||
59 | * Gets as namespace |
||
60 | * |
||
61 | * @return string |
||
62 | */ |
||
63 | public function getNamespace() |
||
67 | |||
68 | /** |
||
69 | * Sets a new namespace |
||
70 | * |
||
71 | * @param string $namespace |
||
72 | * @return self |
||
73 | */ |
||
74 | public function setNamespace($namespace) |
||
79 | |||
80 | /** |
||
81 | * Gets as alias |
||
82 | * |
||
83 | * @return string |
||
84 | */ |
||
85 | public function getAlias() |
||
89 | |||
90 | /** |
||
91 | * Sets a new alias |
||
92 | * |
||
93 | * @param string $alias |
||
94 | * @return self |
||
95 | */ |
||
96 | public function setAlias($alias) |
||
101 | |||
102 | /** |
||
103 | * Gets as provider |
||
104 | * |
||
105 | * @return string |
||
106 | */ |
||
107 | public function getProvider() |
||
111 | |||
112 | /** |
||
113 | * Sets a new provider |
||
114 | * |
||
115 | * @param string $provider |
||
116 | * @return self |
||
117 | */ |
||
118 | public function setProvider($provider) |
||
123 | |||
124 | /** |
||
125 | * Gets as providerManifestToken |
||
126 | * |
||
127 | * @return string |
||
128 | */ |
||
129 | public function getProviderManifestToken() |
||
133 | |||
134 | /** |
||
135 | * Sets a new providerManifestToken |
||
136 | * |
||
137 | * @param string $providerManifestToken |
||
138 | * @return self |
||
139 | */ |
||
140 | public function setProviderManifestToken($providerManifestToken) |
||
145 | |||
146 | /** |
||
147 | * Adds as association |
||
148 | * |
||
149 | * @return self |
||
150 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TAssociationType $association |
||
151 | */ |
||
152 | public function addToAssociation(TAssociationType $association) |
||
157 | |||
158 | /** |
||
159 | * isset association |
||
160 | * |
||
161 | * @param scalar $index |
||
162 | * @return boolean |
||
163 | */ |
||
164 | public function issetAssociation($index) |
||
168 | |||
169 | /** |
||
170 | * unset association |
||
171 | * |
||
172 | * @param scalar $index |
||
173 | * @return void |
||
174 | */ |
||
175 | public function unsetAssociation($index) |
||
179 | |||
180 | /** |
||
181 | * Gets as association |
||
182 | * |
||
183 | * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TAssociationType[] |
||
184 | */ |
||
185 | public function getAssociation() |
||
189 | |||
190 | /** |
||
191 | * Sets a new association |
||
192 | * |
||
193 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TAssociationType[] $association |
||
194 | * @return self |
||
195 | */ |
||
196 | public function setAssociation(array $association) |
||
201 | |||
202 | /** |
||
203 | * Adds as entityType |
||
204 | * |
||
205 | * @return self |
||
206 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TEntityTypeType $entityType |
||
207 | */ |
||
208 | public function addToEntityType(TEntityTypeType $entityType) |
||
213 | |||
214 | /** |
||
215 | * isset entityType |
||
216 | * |
||
217 | * @param scalar $index |
||
218 | * @return boolean |
||
219 | */ |
||
220 | public function issetEntityType($index) |
||
224 | |||
225 | /** |
||
226 | * unset entityType |
||
227 | * |
||
228 | * @param scalar $index |
||
229 | * @return void |
||
230 | */ |
||
231 | public function unsetEntityType($index) |
||
235 | |||
236 | /** |
||
237 | * Gets as entityType |
||
238 | * |
||
239 | * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TEntityTypeType[] |
||
240 | */ |
||
241 | public function getEntityType() |
||
245 | |||
246 | /** |
||
247 | * Sets a new entityType |
||
248 | * |
||
249 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TEntityTypeType[] $entityType |
||
250 | * @return self |
||
251 | */ |
||
252 | public function setEntityType(array $entityType) |
||
257 | |||
258 | /** |
||
259 | * Adds as entityContainer |
||
260 | * |
||
261 | * @return self |
||
262 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\EntityContainer $entityContainer |
||
263 | */ |
||
264 | public function addToEntityContainer(EntityContainer $entityContainer) |
||
269 | |||
270 | /** |
||
271 | * isset entityContainer |
||
272 | * |
||
273 | * @param scalar $index |
||
274 | * @return boolean |
||
275 | */ |
||
276 | public function issetEntityContainer($index) |
||
280 | |||
281 | /** |
||
282 | * unset entityContainer |
||
283 | * |
||
284 | * @param scalar $index |
||
285 | * @return void |
||
286 | */ |
||
287 | public function unsetEntityContainer($index) |
||
291 | |||
292 | /** |
||
293 | * Gets as entityContainer |
||
294 | * |
||
295 | * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\EntityContainer[] |
||
296 | */ |
||
297 | public function getEntityContainer() |
||
301 | |||
302 | /** |
||
303 | * Sets a new entityContainer |
||
304 | * |
||
305 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\EntityContainer[] $entityContainer |
||
306 | * @return self |
||
307 | */ |
||
308 | public function setEntityContainer(array $entityContainer) |
||
313 | |||
314 | /** |
||
315 | * Adds as function |
||
316 | * |
||
317 | * @return self |
||
318 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TFunctionType $function |
||
319 | */ |
||
320 | public function addToFunction(TFunctionType $function) |
||
325 | |||
326 | /** |
||
327 | * isset function |
||
328 | * |
||
329 | * @param scalar $index |
||
330 | * @return boolean |
||
331 | */ |
||
332 | public function issetFunction($index) |
||
336 | |||
337 | /** |
||
338 | * unset function |
||
339 | * |
||
340 | * @param scalar $index |
||
341 | * @return void |
||
342 | */ |
||
343 | public function unsetFunction($index) |
||
347 | |||
348 | /** |
||
349 | * Gets as function |
||
350 | * |
||
351 | * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TFunctionType[] |
||
352 | */ |
||
353 | public function getFunction() |
||
357 | |||
358 | /** |
||
359 | * Sets a new function |
||
360 | * |
||
361 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\ssdl\TFunctionType[] $function |
||
362 | * @return self |
||
363 | */ |
||
364 | public function setFunction(array $function) |
||
369 | |||
370 | public function isOK(&$msg = null) |
||
436 | } |
||
437 |