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 |
||
| 11 | class TSchemaType |
||
| 12 | { |
||
| 13 | |||
| 14 | /** |
||
| 15 | * @property string $namespace |
||
| 16 | */ |
||
| 17 | private $namespace = null; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @property string $namespaceUri |
||
| 21 | */ |
||
| 22 | private $namespaceUri = null; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @property string $alias |
||
| 26 | */ |
||
| 27 | private $alias = null; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @property \MetadataV3\edm\TUsingType[] $using |
||
| 31 | */ |
||
| 32 | private $using = array( |
||
| 33 | |||
| 34 | ); |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @property \MetadataV3\edm\TAssociationType[] $association |
||
| 38 | */ |
||
| 39 | private $association = array( |
||
| 40 | |||
| 41 | ); |
||
| 42 | |||
| 43 | /** |
||
| 44 | * @property \MetadataV3\edm\TComplexTypeType[] $complexType |
||
| 45 | */ |
||
| 46 | private $complexType = array( |
||
| 47 | |||
| 48 | ); |
||
| 49 | |||
| 50 | /** |
||
| 51 | * @property \MetadataV3\edm\TEntityTypeType[] $entityType |
||
| 52 | */ |
||
| 53 | private $entityType = array( |
||
| 54 | |||
| 55 | ); |
||
| 56 | |||
| 57 | /** |
||
| 58 | * @property \MetadataV3\edm\TEnumTypeType[] $enumType |
||
| 59 | */ |
||
| 60 | private $enumType = array( |
||
| 61 | |||
| 62 | ); |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @property \MetadataV3\edm\TValueTermType[] $valueTerm |
||
| 66 | */ |
||
| 67 | private $valueTerm = array( |
||
| 68 | |||
| 69 | ); |
||
| 70 | |||
| 71 | /** |
||
| 72 | * @property \MetadataV3\edm\TFunctionType[] $function |
||
| 73 | */ |
||
| 74 | private $function = array( |
||
| 75 | |||
| 76 | ); |
||
| 77 | |||
| 78 | /** |
||
| 79 | * @property \MetadataV3\edm\TAnnotationsType[] $annotations |
||
| 80 | */ |
||
| 81 | private $annotations = array( |
||
| 82 | |||
| 83 | ); |
||
| 84 | |||
| 85 | /** |
||
| 86 | * @property \MetadataV3\edm\EntityContainer[] $entityContainer |
||
| 87 | */ |
||
| 88 | private $entityContainer = array( |
||
| 89 | |||
| 90 | ); |
||
| 91 | |||
| 92 | /** |
||
| 93 | * Gets as namespace |
||
| 94 | * |
||
| 95 | * @return string |
||
| 96 | */ |
||
| 97 | public function getNamespace() |
||
| 101 | |||
| 102 | /** |
||
| 103 | * Sets a new namespace |
||
| 104 | * |
||
| 105 | * @param string $namespace |
||
| 106 | * @return self |
||
| 107 | */ |
||
| 108 | public function setNamespace($namespace) |
||
| 113 | |||
| 114 | /** |
||
| 115 | * Gets as namespaceUri |
||
| 116 | * |
||
| 117 | * @return string |
||
| 118 | */ |
||
| 119 | public function getNamespaceUri() |
||
| 123 | |||
| 124 | /** |
||
| 125 | * Sets a new namespaceUri |
||
| 126 | * |
||
| 127 | * @param string $namespaceUri |
||
| 128 | * @return self |
||
| 129 | */ |
||
| 130 | public function setNamespaceUri($namespaceUri) |
||
| 135 | |||
| 136 | /** |
||
| 137 | * Gets as alias |
||
| 138 | * |
||
| 139 | * @return string |
||
| 140 | */ |
||
| 141 | public function getAlias() |
||
| 145 | |||
| 146 | /** |
||
| 147 | * Sets a new alias |
||
| 148 | * |
||
| 149 | * @param string $alias |
||
| 150 | * @return self |
||
| 151 | */ |
||
| 152 | public function setAlias($alias) |
||
| 157 | |||
| 158 | /** |
||
| 159 | * Adds as using |
||
| 160 | * |
||
| 161 | * @return self |
||
| 162 | * @param \MetadataV3\edm\TUsingType $using |
||
| 163 | */ |
||
| 164 | public function addToUsing(\MetadataV3\edm\TUsingType $using) |
||
| 169 | |||
| 170 | /** |
||
| 171 | * isset using |
||
| 172 | * |
||
| 173 | * @param scalar $index |
||
| 174 | * @return boolean |
||
| 175 | */ |
||
| 176 | public function issetUsing($index) |
||
| 180 | |||
| 181 | /** |
||
| 182 | * unset using |
||
| 183 | * |
||
| 184 | * @param scalar $index |
||
| 185 | * @return void |
||
| 186 | */ |
||
| 187 | public function unsetUsing($index) |
||
| 191 | |||
| 192 | /** |
||
| 193 | * Gets as using |
||
| 194 | * |
||
| 195 | * @return \MetadataV3\edm\TUsingType[] |
||
| 196 | */ |
||
| 197 | public function getUsing() |
||
| 201 | |||
| 202 | /** |
||
| 203 | * Sets a new using |
||
| 204 | * |
||
| 205 | * @param \MetadataV3\edm\TUsingType[] $using |
||
| 206 | * @return self |
||
| 207 | */ |
||
| 208 | public function setUsing(array $using) |
||
| 213 | |||
| 214 | /** |
||
| 215 | * Adds as association |
||
| 216 | * |
||
| 217 | * @return self |
||
| 218 | * @param \MetadataV3\edm\TAssociationType $association |
||
| 219 | */ |
||
| 220 | public function addToAssociation(\MetadataV3\edm\TAssociationType $association) |
||
| 225 | |||
| 226 | /** |
||
| 227 | * isset association |
||
| 228 | * |
||
| 229 | * @param scalar $index |
||
| 230 | * @return boolean |
||
| 231 | */ |
||
| 232 | public function issetAssociation($index) |
||
| 236 | |||
| 237 | /** |
||
| 238 | * unset association |
||
| 239 | * |
||
| 240 | * @param scalar $index |
||
| 241 | * @return void |
||
| 242 | */ |
||
| 243 | public function unsetAssociation($index) |
||
| 247 | |||
| 248 | /** |
||
| 249 | * Gets as association |
||
| 250 | * |
||
| 251 | * @return \MetadataV3\edm\TAssociationType[] |
||
| 252 | */ |
||
| 253 | public function getAssociation() |
||
| 257 | |||
| 258 | /** |
||
| 259 | * Sets a new association |
||
| 260 | * |
||
| 261 | * @param \MetadataV3\edm\TAssociationType[] $association |
||
| 262 | * @return self |
||
| 263 | */ |
||
| 264 | public function setAssociation(array $association) |
||
| 269 | |||
| 270 | /** |
||
| 271 | * Adds as complexType |
||
| 272 | * |
||
| 273 | * @return self |
||
| 274 | * @param \MetadataV3\edm\TComplexTypeType $complexType |
||
| 275 | */ |
||
| 276 | public function addToComplexType(\MetadataV3\edm\TComplexTypeType $complexType) |
||
| 281 | |||
| 282 | /** |
||
| 283 | * isset complexType |
||
| 284 | * |
||
| 285 | * @param scalar $index |
||
| 286 | * @return boolean |
||
| 287 | */ |
||
| 288 | public function issetComplexType($index) |
||
| 292 | |||
| 293 | /** |
||
| 294 | * unset complexType |
||
| 295 | * |
||
| 296 | * @param scalar $index |
||
| 297 | * @return void |
||
| 298 | */ |
||
| 299 | public function unsetComplexType($index) |
||
| 303 | |||
| 304 | /** |
||
| 305 | * Gets as complexType |
||
| 306 | * |
||
| 307 | * @return \MetadataV3\edm\TComplexTypeType[] |
||
| 308 | */ |
||
| 309 | public function getComplexType() |
||
| 313 | |||
| 314 | /** |
||
| 315 | * Sets a new complexType |
||
| 316 | * |
||
| 317 | * @param \MetadataV3\edm\TComplexTypeType[] $complexType |
||
| 318 | * @return self |
||
| 319 | */ |
||
| 320 | public function setComplexType(array $complexType) |
||
| 325 | |||
| 326 | /** |
||
| 327 | * Adds as entityType |
||
| 328 | * |
||
| 329 | * @return self |
||
| 330 | * @param \MetadataV3\edm\TEntityTypeType $entityType |
||
| 331 | */ |
||
| 332 | public function addToEntityType(\MetadataV3\edm\TEntityTypeType $entityType) |
||
| 337 | |||
| 338 | /** |
||
| 339 | * isset entityType |
||
| 340 | * |
||
| 341 | * @param scalar $index |
||
| 342 | * @return boolean |
||
| 343 | */ |
||
| 344 | public function issetEntityType($index) |
||
| 348 | |||
| 349 | /** |
||
| 350 | * unset entityType |
||
| 351 | * |
||
| 352 | * @param scalar $index |
||
| 353 | * @return void |
||
| 354 | */ |
||
| 355 | public function unsetEntityType($index) |
||
| 359 | |||
| 360 | /** |
||
| 361 | * Gets as entityType |
||
| 362 | * |
||
| 363 | * @return \MetadataV3\edm\TEntityTypeType[] |
||
| 364 | */ |
||
| 365 | public function getEntityType() |
||
| 369 | |||
| 370 | /** |
||
| 371 | * Sets a new entityType |
||
| 372 | * |
||
| 373 | * @param \MetadataV3\edm\TEntityTypeType[] $entityType |
||
| 374 | * @return self |
||
| 375 | */ |
||
| 376 | public function setEntityType(array $entityType) |
||
| 381 | |||
| 382 | /** |
||
| 383 | * Adds as enumType |
||
| 384 | * |
||
| 385 | * @return self |
||
| 386 | * @param \MetadataV3\edm\TEnumTypeType $enumType |
||
| 387 | */ |
||
| 388 | public function addToEnumType(\MetadataV3\edm\TEnumTypeType $enumType) |
||
| 393 | |||
| 394 | /** |
||
| 395 | * isset enumType |
||
| 396 | * |
||
| 397 | * @param scalar $index |
||
| 398 | * @return boolean |
||
| 399 | */ |
||
| 400 | public function issetEnumType($index) |
||
| 404 | |||
| 405 | /** |
||
| 406 | * unset enumType |
||
| 407 | * |
||
| 408 | * @param scalar $index |
||
| 409 | * @return void |
||
| 410 | */ |
||
| 411 | public function unsetEnumType($index) |
||
| 415 | |||
| 416 | /** |
||
| 417 | * Gets as enumType |
||
| 418 | * |
||
| 419 | * @return \MetadataV3\edm\TEnumTypeType[] |
||
| 420 | */ |
||
| 421 | public function getEnumType() |
||
| 425 | |||
| 426 | /** |
||
| 427 | * Sets a new enumType |
||
| 428 | * |
||
| 429 | * @param \MetadataV3\edm\TEnumTypeType[] $enumType |
||
| 430 | * @return self |
||
| 431 | */ |
||
| 432 | public function setEnumType(array $enumType) |
||
| 437 | |||
| 438 | /** |
||
| 439 | * Adds as valueTerm |
||
| 440 | * |
||
| 441 | * @return self |
||
| 442 | * @param \MetadataV3\edm\TValueTermType $valueTerm |
||
| 443 | */ |
||
| 444 | public function addToValueTerm(\MetadataV3\edm\TValueTermType $valueTerm) |
||
| 449 | |||
| 450 | /** |
||
| 451 | * isset valueTerm |
||
| 452 | * |
||
| 453 | * @param scalar $index |
||
| 454 | * @return boolean |
||
| 455 | */ |
||
| 456 | public function issetValueTerm($index) |
||
| 460 | |||
| 461 | /** |
||
| 462 | * unset valueTerm |
||
| 463 | * |
||
| 464 | * @param scalar $index |
||
| 465 | * @return void |
||
| 466 | */ |
||
| 467 | public function unsetValueTerm($index) |
||
| 471 | |||
| 472 | /** |
||
| 473 | * Gets as valueTerm |
||
| 474 | * |
||
| 475 | * @return \MetadataV3\edm\TValueTermType[] |
||
| 476 | */ |
||
| 477 | public function getValueTerm() |
||
| 481 | |||
| 482 | /** |
||
| 483 | * Sets a new valueTerm |
||
| 484 | * |
||
| 485 | * @param \MetadataV3\edm\TValueTermType[] $valueTerm |
||
| 486 | * @return self |
||
| 487 | */ |
||
| 488 | public function setValueTerm(array $valueTerm) |
||
| 493 | |||
| 494 | /** |
||
| 495 | * Adds as function |
||
| 496 | * |
||
| 497 | * @return self |
||
| 498 | * @param \MetadataV3\edm\TFunctionType $function |
||
| 499 | */ |
||
| 500 | public function addToFunction(\MetadataV3\edm\TFunctionType $function) |
||
| 505 | |||
| 506 | /** |
||
| 507 | * isset function |
||
| 508 | * |
||
| 509 | * @param scalar $index |
||
| 510 | * @return boolean |
||
| 511 | */ |
||
| 512 | public function issetFunction($index) |
||
| 516 | |||
| 517 | /** |
||
| 518 | * unset function |
||
| 519 | * |
||
| 520 | * @param scalar $index |
||
| 521 | * @return void |
||
| 522 | */ |
||
| 523 | public function unsetFunction($index) |
||
| 527 | |||
| 528 | /** |
||
| 529 | * Gets as function |
||
| 530 | * |
||
| 531 | * @return \MetadataV3\edm\TFunctionType[] |
||
| 532 | */ |
||
| 533 | public function getFunction() |
||
| 537 | |||
| 538 | /** |
||
| 539 | * Sets a new function |
||
| 540 | * |
||
| 541 | * @param \MetadataV3\edm\TFunctionType[] $function |
||
| 542 | * @return self |
||
| 543 | */ |
||
| 544 | public function setFunction(array $function) |
||
| 549 | |||
| 550 | /** |
||
| 551 | * Adds as annotations |
||
| 552 | * |
||
| 553 | * @return self |
||
| 554 | * @param \MetadataV3\edm\TAnnotationsType $annotations |
||
| 555 | */ |
||
| 556 | public function addToAnnotations(\MetadataV3\edm\TAnnotationsType $annotations) |
||
| 561 | |||
| 562 | /** |
||
| 563 | * isset annotations |
||
| 564 | * |
||
| 565 | * @param scalar $index |
||
| 566 | * @return boolean |
||
| 567 | */ |
||
| 568 | public function issetAnnotations($index) |
||
| 572 | |||
| 573 | /** |
||
| 574 | * unset annotations |
||
| 575 | * |
||
| 576 | * @param scalar $index |
||
| 577 | * @return void |
||
| 578 | */ |
||
| 579 | public function unsetAnnotations($index) |
||
| 583 | |||
| 584 | /** |
||
| 585 | * Gets as annotations |
||
| 586 | * |
||
| 587 | * @return \MetadataV3\edm\TAnnotationsType[] |
||
| 588 | */ |
||
| 589 | public function getAnnotations() |
||
| 593 | |||
| 594 | /** |
||
| 595 | * Sets a new annotations |
||
| 596 | * |
||
| 597 | * @param \MetadataV3\edm\TAnnotationsType[] $annotations |
||
| 598 | * @return self |
||
| 599 | */ |
||
| 600 | public function setAnnotations(array $annotations) |
||
| 605 | |||
| 606 | /** |
||
| 607 | * Adds as entityContainer |
||
| 608 | * |
||
| 609 | * @return self |
||
| 610 | * @param \MetadataV3\edm\EntityContainer $entityContainer |
||
| 611 | */ |
||
| 612 | public function addToEntityContainer(\MetadataV3\edm\EntityContainer $entityContainer) |
||
| 617 | |||
| 618 | /** |
||
| 619 | * isset entityContainer |
||
| 620 | * |
||
| 621 | * @param scalar $index |
||
| 622 | * @return boolean |
||
| 623 | */ |
||
| 624 | public function issetEntityContainer($index) |
||
| 628 | |||
| 629 | /** |
||
| 630 | * unset entityContainer |
||
| 631 | * |
||
| 632 | * @param scalar $index |
||
| 633 | * @return void |
||
| 634 | */ |
||
| 635 | public function unsetEntityContainer($index) |
||
| 639 | |||
| 640 | /** |
||
| 641 | * Gets as entityContainer |
||
| 642 | * |
||
| 643 | * @return \MetadataV3\edm\EntityContainer[] |
||
| 644 | */ |
||
| 645 | public function getEntityContainer() |
||
| 649 | |||
| 650 | /** |
||
| 651 | * Sets a new entityContainer |
||
| 652 | * |
||
| 653 | * @param \MetadataV3\edm\EntityContainer[] $entityContainer |
||
| 654 | * @return self |
||
| 655 | */ |
||
| 656 | public function setEntityContainer(array $entityContainer) |
||
| 661 | } |
||
| 662 |