Complex classes like Schema 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 Schema, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
8 | class Schema |
||
9 | { |
||
10 | |||
11 | /** |
||
12 | * @property string $namespace |
||
13 | */ |
||
14 | private $namespace = null; |
||
15 | |||
16 | /** |
||
17 | * @property string $alias |
||
18 | */ |
||
19 | private $alias = null; |
||
20 | |||
21 | /** |
||
22 | * @property \MetadataV4\edm\TComplexTypeType[] $complexType |
||
23 | */ |
||
24 | private $complexType = array( |
||
25 | |||
26 | ); |
||
27 | |||
28 | /** |
||
29 | * @property \MetadataV4\edm\TEntityTypeType[] $entityType |
||
30 | */ |
||
31 | private $entityType = array( |
||
32 | |||
33 | ); |
||
34 | |||
35 | /** |
||
36 | * @property \MetadataV4\edm\TTypeDefinitionType[] $typeDefinition |
||
37 | */ |
||
38 | private $typeDefinition = array( |
||
39 | |||
40 | ); |
||
41 | |||
42 | /** |
||
43 | * @property \MetadataV4\edm\TEnumTypeType[] $enumType |
||
44 | */ |
||
45 | private $enumType = array( |
||
46 | |||
47 | ); |
||
48 | |||
49 | /** |
||
50 | * @property \MetadataV4\edm\TActionType[] $action |
||
51 | */ |
||
52 | private $action = array( |
||
53 | |||
54 | ); |
||
55 | |||
56 | /** |
||
57 | * @property \MetadataV4\edm\TFunctionType[] $function |
||
58 | */ |
||
59 | private $function = array( |
||
60 | |||
61 | ); |
||
62 | |||
63 | /** |
||
64 | * @property \MetadataV4\edm\TTermType[] $term |
||
65 | */ |
||
66 | private $term = array( |
||
67 | |||
68 | ); |
||
69 | |||
70 | /** |
||
71 | * @property \MetadataV4\edm\TAnnotationsType[] $annotations |
||
72 | */ |
||
73 | private $annotations = array( |
||
74 | |||
75 | ); |
||
76 | |||
77 | /** |
||
78 | * @property \MetadataV4\edm\TEntityContainerType[] $entityContainer |
||
79 | */ |
||
80 | private $entityContainer = array( |
||
81 | |||
82 | ); |
||
83 | |||
84 | /** |
||
85 | * @property \MetadataV4\edm\Annotation[] $annotation |
||
86 | */ |
||
87 | private $annotation = array( |
||
88 | |||
89 | ); |
||
90 | |||
91 | /** |
||
92 | * Gets as namespace |
||
93 | * |
||
94 | * @return string |
||
95 | */ |
||
96 | public function getNamespace() |
||
100 | |||
101 | /** |
||
102 | * Sets a new namespace |
||
103 | * |
||
104 | * @param string $namespace |
||
105 | * @return self |
||
106 | */ |
||
107 | public function setNamespace($namespace) |
||
112 | |||
113 | /** |
||
114 | * Gets as alias |
||
115 | * |
||
116 | * @return string |
||
117 | */ |
||
118 | public function getAlias() |
||
122 | |||
123 | /** |
||
124 | * Sets a new alias |
||
125 | * |
||
126 | * @param string $alias |
||
127 | * @return self |
||
128 | */ |
||
129 | public function setAlias($alias) |
||
134 | |||
135 | /** |
||
136 | * Adds as complexType |
||
137 | * |
||
138 | * @return self |
||
139 | * @param \MetadataV4\edm\TComplexTypeType $complexType |
||
140 | */ |
||
141 | public function addToComplexType(\MetadataV4\edm\TComplexTypeType $complexType) |
||
146 | |||
147 | /** |
||
148 | * isset complexType |
||
149 | * |
||
150 | * @param scalar $index |
||
151 | * @return boolean |
||
152 | */ |
||
153 | public function issetComplexType($index) |
||
157 | |||
158 | /** |
||
159 | * unset complexType |
||
160 | * |
||
161 | * @param scalar $index |
||
162 | * @return void |
||
163 | */ |
||
164 | public function unsetComplexType($index) |
||
168 | |||
169 | /** |
||
170 | * Gets as complexType |
||
171 | * |
||
172 | * @return \MetadataV4\edm\TComplexTypeType[] |
||
173 | */ |
||
174 | public function getComplexType() |
||
178 | |||
179 | /** |
||
180 | * Sets a new complexType |
||
181 | * |
||
182 | * @param \MetadataV4\edm\TComplexTypeType[] $complexType |
||
183 | * @return self |
||
184 | */ |
||
185 | public function setComplexType(array $complexType) |
||
190 | |||
191 | /** |
||
192 | * Adds as entityType |
||
193 | * |
||
194 | * @return self |
||
195 | * @param \MetadataV4\edm\TEntityTypeType $entityType |
||
196 | */ |
||
197 | public function addToEntityType(\MetadataV4\edm\TEntityTypeType $entityType) |
||
202 | |||
203 | /** |
||
204 | * isset entityType |
||
205 | * |
||
206 | * @param scalar $index |
||
207 | * @return boolean |
||
208 | */ |
||
209 | public function issetEntityType($index) |
||
213 | |||
214 | /** |
||
215 | * unset entityType |
||
216 | * |
||
217 | * @param scalar $index |
||
218 | * @return void |
||
219 | */ |
||
220 | public function unsetEntityType($index) |
||
224 | |||
225 | /** |
||
226 | * Gets as entityType |
||
227 | * |
||
228 | * @return \MetadataV4\edm\TEntityTypeType[] |
||
229 | */ |
||
230 | public function getEntityType() |
||
234 | |||
235 | /** |
||
236 | * Sets a new entityType |
||
237 | * |
||
238 | * @param \MetadataV4\edm\TEntityTypeType[] $entityType |
||
239 | * @return self |
||
240 | */ |
||
241 | public function setEntityType(array $entityType) |
||
246 | |||
247 | /** |
||
248 | * Adds as typeDefinition |
||
249 | * |
||
250 | * @return self |
||
251 | * @param \MetadataV4\edm\TTypeDefinitionType $typeDefinition |
||
252 | */ |
||
253 | public function addToTypeDefinition(\MetadataV4\edm\TTypeDefinitionType $typeDefinition) |
||
258 | |||
259 | /** |
||
260 | * isset typeDefinition |
||
261 | * |
||
262 | * @param scalar $index |
||
263 | * @return boolean |
||
264 | */ |
||
265 | public function issetTypeDefinition($index) |
||
269 | |||
270 | /** |
||
271 | * unset typeDefinition |
||
272 | * |
||
273 | * @param scalar $index |
||
274 | * @return void |
||
275 | */ |
||
276 | public function unsetTypeDefinition($index) |
||
280 | |||
281 | /** |
||
282 | * Gets as typeDefinition |
||
283 | * |
||
284 | * @return \MetadataV4\edm\TTypeDefinitionType[] |
||
285 | */ |
||
286 | public function getTypeDefinition() |
||
290 | |||
291 | /** |
||
292 | * Sets a new typeDefinition |
||
293 | * |
||
294 | * @param \MetadataV4\edm\TTypeDefinitionType[] $typeDefinition |
||
295 | * @return self |
||
296 | */ |
||
297 | public function setTypeDefinition(array $typeDefinition) |
||
302 | |||
303 | /** |
||
304 | * Adds as enumType |
||
305 | * |
||
306 | * @return self |
||
307 | * @param \MetadataV4\edm\TEnumTypeType $enumType |
||
308 | */ |
||
309 | public function addToEnumType(\MetadataV4\edm\TEnumTypeType $enumType) |
||
314 | |||
315 | /** |
||
316 | * isset enumType |
||
317 | * |
||
318 | * @param scalar $index |
||
319 | * @return boolean |
||
320 | */ |
||
321 | public function issetEnumType($index) |
||
325 | |||
326 | /** |
||
327 | * unset enumType |
||
328 | * |
||
329 | * @param scalar $index |
||
330 | * @return void |
||
331 | */ |
||
332 | public function unsetEnumType($index) |
||
336 | |||
337 | /** |
||
338 | * Gets as enumType |
||
339 | * |
||
340 | * @return \MetadataV4\edm\TEnumTypeType[] |
||
341 | */ |
||
342 | public function getEnumType() |
||
346 | |||
347 | /** |
||
348 | * Sets a new enumType |
||
349 | * |
||
350 | * @param \MetadataV4\edm\TEnumTypeType[] $enumType |
||
351 | * @return self |
||
352 | */ |
||
353 | public function setEnumType(array $enumType) |
||
358 | |||
359 | /** |
||
360 | * Adds as action |
||
361 | * |
||
362 | * @return self |
||
363 | * @param \MetadataV4\edm\TActionType $action |
||
364 | */ |
||
365 | public function addToAction(\MetadataV4\edm\TActionType $action) |
||
370 | |||
371 | /** |
||
372 | * isset action |
||
373 | * |
||
374 | * @param scalar $index |
||
375 | * @return boolean |
||
376 | */ |
||
377 | public function issetAction($index) |
||
381 | |||
382 | /** |
||
383 | * unset action |
||
384 | * |
||
385 | * @param scalar $index |
||
386 | * @return void |
||
387 | */ |
||
388 | public function unsetAction($index) |
||
392 | |||
393 | /** |
||
394 | * Gets as action |
||
395 | * |
||
396 | * @return \MetadataV4\edm\TActionType[] |
||
397 | */ |
||
398 | public function getAction() |
||
402 | |||
403 | /** |
||
404 | * Sets a new action |
||
405 | * |
||
406 | * @param \MetadataV4\edm\TActionType[] $action |
||
407 | * @return self |
||
408 | */ |
||
409 | public function setAction(array $action) |
||
414 | |||
415 | /** |
||
416 | * Adds as function |
||
417 | * |
||
418 | * @return self |
||
419 | * @param \MetadataV4\edm\TFunctionType $function |
||
420 | */ |
||
421 | public function addToFunction(\MetadataV4\edm\TFunctionType $function) |
||
426 | |||
427 | /** |
||
428 | * isset function |
||
429 | * |
||
430 | * @param scalar $index |
||
431 | * @return boolean |
||
432 | */ |
||
433 | public function issetFunction($index) |
||
437 | |||
438 | /** |
||
439 | * unset function |
||
440 | * |
||
441 | * @param scalar $index |
||
442 | * @return void |
||
443 | */ |
||
444 | public function unsetFunction($index) |
||
448 | |||
449 | /** |
||
450 | * Gets as function |
||
451 | * |
||
452 | * @return \MetadataV4\edm\TFunctionType[] |
||
453 | */ |
||
454 | public function getFunction() |
||
458 | |||
459 | /** |
||
460 | * Sets a new function |
||
461 | * |
||
462 | * @param \MetadataV4\edm\TFunctionType[] $function |
||
463 | * @return self |
||
464 | */ |
||
465 | public function setFunction(array $function) |
||
470 | |||
471 | /** |
||
472 | * Adds as term |
||
473 | * |
||
474 | * @return self |
||
475 | * @param \MetadataV4\edm\TTermType $term |
||
476 | */ |
||
477 | public function addToTerm(\MetadataV4\edm\TTermType $term) |
||
482 | |||
483 | /** |
||
484 | * isset term |
||
485 | * |
||
486 | * @param scalar $index |
||
487 | * @return boolean |
||
488 | */ |
||
489 | public function issetTerm($index) |
||
493 | |||
494 | /** |
||
495 | * unset term |
||
496 | * |
||
497 | * @param scalar $index |
||
498 | * @return void |
||
499 | */ |
||
500 | public function unsetTerm($index) |
||
504 | |||
505 | /** |
||
506 | * Gets as term |
||
507 | * |
||
508 | * @return \MetadataV4\edm\TTermType[] |
||
509 | */ |
||
510 | public function getTerm() |
||
514 | |||
515 | /** |
||
516 | * Sets a new term |
||
517 | * |
||
518 | * @param \MetadataV4\edm\TTermType[] $term |
||
519 | * @return self |
||
520 | */ |
||
521 | public function setTerm(array $term) |
||
526 | |||
527 | /** |
||
528 | * Adds as annotations |
||
529 | * |
||
530 | * @return self |
||
531 | * @param \MetadataV4\edm\TAnnotationsType $annotations |
||
532 | */ |
||
533 | public function addToAnnotations(\MetadataV4\edm\TAnnotationsType $annotations) |
||
538 | |||
539 | /** |
||
540 | * isset annotations |
||
541 | * |
||
542 | * @param scalar $index |
||
543 | * @return boolean |
||
544 | */ |
||
545 | public function issetAnnotations($index) |
||
549 | |||
550 | /** |
||
551 | * unset annotations |
||
552 | * |
||
553 | * @param scalar $index |
||
554 | * @return void |
||
555 | */ |
||
556 | public function unsetAnnotations($index) |
||
560 | |||
561 | /** |
||
562 | * Gets as annotations |
||
563 | * |
||
564 | * @return \MetadataV4\edm\TAnnotationsType[] |
||
565 | */ |
||
566 | public function getAnnotations() |
||
570 | |||
571 | /** |
||
572 | * Sets a new annotations |
||
573 | * |
||
574 | * @param \MetadataV4\edm\TAnnotationsType[] $annotations |
||
575 | * @return self |
||
576 | */ |
||
577 | public function setAnnotations(array $annotations) |
||
582 | |||
583 | /** |
||
584 | * Adds as entityContainer |
||
585 | * |
||
586 | * @return self |
||
587 | * @param \MetadataV4\edm\TEntityContainerType $entityContainer |
||
588 | */ |
||
589 | public function addToEntityContainer(\MetadataV4\edm\TEntityContainerType $entityContainer) |
||
594 | |||
595 | /** |
||
596 | * isset entityContainer |
||
597 | * |
||
598 | * @param scalar $index |
||
599 | * @return boolean |
||
600 | */ |
||
601 | public function issetEntityContainer($index) |
||
605 | |||
606 | /** |
||
607 | * unset entityContainer |
||
608 | * |
||
609 | * @param scalar $index |
||
610 | * @return void |
||
611 | */ |
||
612 | public function unsetEntityContainer($index) |
||
616 | |||
617 | /** |
||
618 | * Gets as entityContainer |
||
619 | * |
||
620 | * @return \MetadataV4\edm\TEntityContainerType[] |
||
621 | */ |
||
622 | public function getEntityContainer() |
||
626 | |||
627 | /** |
||
628 | * Sets a new entityContainer |
||
629 | * |
||
630 | * @param \MetadataV4\edm\TEntityContainerType[] $entityContainer |
||
631 | * @return self |
||
632 | */ |
||
633 | public function setEntityContainer(array $entityContainer) |
||
638 | |||
639 | /** |
||
640 | * Adds as annotation |
||
641 | * |
||
642 | * @return self |
||
643 | * @param \MetadataV4\edm\Annotation $annotation |
||
644 | */ |
||
645 | public function addToAnnotation(\MetadataV4\edm\Annotation $annotation) |
||
650 | |||
651 | /** |
||
652 | * isset annotation |
||
653 | * |
||
654 | * @param scalar $index |
||
655 | * @return boolean |
||
656 | */ |
||
657 | public function issetAnnotation($index) |
||
661 | |||
662 | /** |
||
663 | * unset annotation |
||
664 | * |
||
665 | * @param scalar $index |
||
666 | * @return void |
||
667 | */ |
||
668 | public function unsetAnnotation($index) |
||
672 | |||
673 | /** |
||
674 | * Gets as annotation |
||
675 | * |
||
676 | * @return \MetadataV4\edm\Annotation[] |
||
677 | */ |
||
678 | public function getAnnotation() |
||
682 | |||
683 | /** |
||
684 | * Sets a new annotation |
||
685 | * |
||
686 | * @param \MetadataV4\edm\Annotation[] $annotation |
||
687 | * @return self |
||
688 | */ |
||
689 | public function setAnnotation(array $annotation) |
||
694 | } |
||
695 |