Complex classes like GSchemaBodyElementsTrait 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 GSchemaBodyElementsTrait, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 16 | trait GSchemaBodyElementsTrait |
||
| 17 | { |
||
| 18 | use IsOKToolboxTrait; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TUsingType[] $using |
||
| 22 | */ |
||
| 23 | private $using = []; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TAssociationType[] $association |
||
| 27 | */ |
||
| 28 | private $association = []; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TComplexTypeType[] $complexType |
||
| 32 | */ |
||
| 33 | private $complexType = []; |
||
| 34 | |||
| 35 | /** |
||
| 36 | * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TEntityTypeType[] $entityType |
||
| 37 | */ |
||
| 38 | private $entityType = []; |
||
| 39 | |||
| 40 | /** |
||
| 41 | * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TEnumTypeType[] $enumType |
||
| 42 | */ |
||
| 43 | private $enumType = []; |
||
| 44 | |||
| 45 | /** |
||
| 46 | * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TValueTermType[] $valueTerm |
||
| 47 | */ |
||
| 48 | private $valueTerm = []; |
||
| 49 | |||
| 50 | /** |
||
| 51 | * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TFunctionType[] $function |
||
| 52 | */ |
||
| 53 | private $function = []; |
||
| 54 | |||
| 55 | /** |
||
| 56 | * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\TAnnotationsType[] $annotations |
||
| 57 | */ |
||
| 58 | private $annotations = []; |
||
| 59 | |||
| 60 | /** |
||
| 61 | * @property \AlgoWeb\ODataMetadata\MetadataV3\edm\EntityContainer[] $entityContainer |
||
| 62 | */ |
||
| 63 | private $entityContainer = []; |
||
| 64 | |||
| 65 | /** |
||
| 66 | * Adds as using |
||
| 67 | * |
||
| 68 | * @return self |
||
| 69 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TUsingType $using |
||
| 70 | */ |
||
| 71 | public function addToUsing(TUsingType $using) |
||
| 76 | |||
| 77 | /** |
||
| 78 | * isset using |
||
| 79 | * |
||
| 80 | * @param scalar $index |
||
| 81 | * @return boolean |
||
| 82 | */ |
||
| 83 | public function issetUsing($index) |
||
| 87 | |||
| 88 | /** |
||
| 89 | * unset using |
||
| 90 | * |
||
| 91 | * @param scalar $index |
||
| 92 | * @return void |
||
| 93 | */ |
||
| 94 | public function unsetUsing($index) |
||
| 98 | |||
| 99 | /** |
||
| 100 | * Gets as using |
||
| 101 | * |
||
| 102 | * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TUsingType[] |
||
| 103 | */ |
||
| 104 | public function getUsing() |
||
| 108 | |||
| 109 | /** |
||
| 110 | * Sets a new using |
||
| 111 | * |
||
| 112 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TUsingType[] $using |
||
| 113 | * @return self |
||
| 114 | */ |
||
| 115 | public function setUsing(array $using) |
||
| 120 | |||
| 121 | /** |
||
| 122 | * Adds as association |
||
| 123 | * |
||
| 124 | * @return self |
||
| 125 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TAssociationType $association |
||
| 126 | */ |
||
| 127 | public function addToAssociation(TAssociationType $association) |
||
| 132 | |||
| 133 | /** |
||
| 134 | * isset association |
||
| 135 | * |
||
| 136 | * @param scalar $index |
||
| 137 | * @return boolean |
||
| 138 | */ |
||
| 139 | public function issetAssociation($index) |
||
| 143 | |||
| 144 | /** |
||
| 145 | * unset association |
||
| 146 | * |
||
| 147 | * @param scalar $index |
||
| 148 | * @return void |
||
| 149 | */ |
||
| 150 | public function unsetAssociation($index) |
||
| 154 | |||
| 155 | /** |
||
| 156 | * Gets as association |
||
| 157 | * |
||
| 158 | * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TAssociationType[] |
||
| 159 | */ |
||
| 160 | public function getAssociation() |
||
| 164 | |||
| 165 | /** |
||
| 166 | * Sets a new association |
||
| 167 | * |
||
| 168 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TAssociationType[] $association |
||
| 169 | * @return self |
||
| 170 | */ |
||
| 171 | public function setAssociation(array $association) |
||
| 176 | |||
| 177 | /** |
||
| 178 | * Adds as complexType |
||
| 179 | * |
||
| 180 | * @return self |
||
| 181 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TComplexTypeType $complexType |
||
| 182 | */ |
||
| 183 | public function addToComplexType(TComplexTypeType $complexType) |
||
| 188 | |||
| 189 | /** |
||
| 190 | * isset complexType |
||
| 191 | * |
||
| 192 | * @param scalar $index |
||
| 193 | * @return boolean |
||
| 194 | */ |
||
| 195 | public function issetComplexType($index) |
||
| 199 | |||
| 200 | /** |
||
| 201 | * unset complexType |
||
| 202 | * |
||
| 203 | * @param scalar $index |
||
| 204 | * @return void |
||
| 205 | */ |
||
| 206 | public function unsetComplexType($index) |
||
| 210 | |||
| 211 | /** |
||
| 212 | * Gets as complexType |
||
| 213 | * |
||
| 214 | * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TComplexTypeType[] |
||
| 215 | */ |
||
| 216 | public function getComplexType() |
||
| 220 | |||
| 221 | /** |
||
| 222 | * Sets a new complexType |
||
| 223 | * |
||
| 224 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TComplexTypeType[] $complexType |
||
| 225 | * @return self |
||
| 226 | */ |
||
| 227 | public function setComplexType(array $complexType) |
||
| 232 | |||
| 233 | /** |
||
| 234 | * Adds as entityType |
||
| 235 | * |
||
| 236 | * @return self |
||
| 237 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TEntityTypeType $entityType |
||
| 238 | */ |
||
| 239 | public function addToEntityType(TEntityTypeType $entityType) |
||
| 244 | |||
| 245 | /** |
||
| 246 | * isset entityType |
||
| 247 | * |
||
| 248 | * @param scalar $index |
||
| 249 | * @return boolean |
||
| 250 | */ |
||
| 251 | public function issetEntityType($index) |
||
| 255 | |||
| 256 | /** |
||
| 257 | * unset entityType |
||
| 258 | * |
||
| 259 | * @param scalar $index |
||
| 260 | * @return void |
||
| 261 | */ |
||
| 262 | public function unsetEntityType($index) |
||
| 266 | |||
| 267 | /** |
||
| 268 | * Gets as entityType |
||
| 269 | * |
||
| 270 | * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TEntityTypeType[] |
||
| 271 | */ |
||
| 272 | public function getEntityType() |
||
| 276 | |||
| 277 | /** |
||
| 278 | * Sets a new entityType |
||
| 279 | * |
||
| 280 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TEntityTypeType[] $entityType |
||
| 281 | * @return self |
||
| 282 | */ |
||
| 283 | public function setEntityType(array $entityType) |
||
| 288 | |||
| 289 | /** |
||
| 290 | * Adds as enumType |
||
| 291 | * |
||
| 292 | * @return self |
||
| 293 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TEnumTypeType $enumType |
||
| 294 | */ |
||
| 295 | public function addToEnumType(TEnumTypeType $enumType) |
||
| 300 | |||
| 301 | /** |
||
| 302 | * isset enumType |
||
| 303 | * |
||
| 304 | * @param scalar $index |
||
| 305 | * @return boolean |
||
| 306 | */ |
||
| 307 | public function issetEnumType($index) |
||
| 311 | |||
| 312 | /** |
||
| 313 | * unset enumType |
||
| 314 | * |
||
| 315 | * @param scalar $index |
||
| 316 | * @return void |
||
| 317 | */ |
||
| 318 | public function unsetEnumType($index) |
||
| 322 | |||
| 323 | /** |
||
| 324 | * Gets as enumType |
||
| 325 | * |
||
| 326 | * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TEnumTypeType[] |
||
| 327 | */ |
||
| 328 | public function getEnumType() |
||
| 332 | |||
| 333 | /** |
||
| 334 | * Sets a new enumType |
||
| 335 | * |
||
| 336 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TEnumTypeType[] $enumType |
||
| 337 | * @return self |
||
| 338 | */ |
||
| 339 | public function setEnumType(array $enumType) |
||
| 344 | |||
| 345 | /** |
||
| 346 | * Adds as valueTerm |
||
| 347 | * |
||
| 348 | * @return self |
||
| 349 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TValueTermType $valueTerm |
||
| 350 | */ |
||
| 351 | public function addToValueTerm(TValueTermType $valueTerm) |
||
| 356 | |||
| 357 | /** |
||
| 358 | * isset valueTerm |
||
| 359 | * |
||
| 360 | * @param scalar $index |
||
| 361 | * @return boolean |
||
| 362 | */ |
||
| 363 | public function issetValueTerm($index) |
||
| 367 | |||
| 368 | /** |
||
| 369 | * unset valueTerm |
||
| 370 | * |
||
| 371 | * @param scalar $index |
||
| 372 | * @return void |
||
| 373 | */ |
||
| 374 | public function unsetValueTerm($index) |
||
| 378 | |||
| 379 | /** |
||
| 380 | * Gets as valueTerm |
||
| 381 | * |
||
| 382 | * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TValueTermType[] |
||
| 383 | */ |
||
| 384 | public function getValueTerm() |
||
| 388 | |||
| 389 | /** |
||
| 390 | * Sets a new valueTerm |
||
| 391 | * |
||
| 392 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TValueTermType[] $valueTerm |
||
| 393 | * @return self |
||
| 394 | */ |
||
| 395 | public function setValueTerm(array $valueTerm) |
||
| 400 | |||
| 401 | /** |
||
| 402 | * Adds as function |
||
| 403 | * |
||
| 404 | * @return self |
||
| 405 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TFunctionType $function |
||
| 406 | */ |
||
| 407 | public function addToFunction(TFunctionType $function) |
||
| 412 | |||
| 413 | /** |
||
| 414 | * isset function |
||
| 415 | * |
||
| 416 | * @param scalar $index |
||
| 417 | * @return boolean |
||
| 418 | */ |
||
| 419 | public function issetFunction($index) |
||
| 423 | |||
| 424 | /** |
||
| 425 | * unset function |
||
| 426 | * |
||
| 427 | * @param scalar $index |
||
| 428 | * @return void |
||
| 429 | */ |
||
| 430 | public function unsetFunction($index) |
||
| 434 | |||
| 435 | /** |
||
| 436 | * Gets as function |
||
| 437 | * |
||
| 438 | * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TFunctionType[] |
||
| 439 | */ |
||
| 440 | public function getFunction() |
||
| 444 | |||
| 445 | /** |
||
| 446 | * Sets a new function |
||
| 447 | * |
||
| 448 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TFunctionType[] $function |
||
| 449 | * @return self |
||
| 450 | */ |
||
| 451 | public function setFunction(array $function) |
||
| 456 | |||
| 457 | /** |
||
| 458 | * Adds as annotations |
||
| 459 | * |
||
| 460 | * @return self |
||
| 461 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TAnnotationsType $annotations |
||
| 462 | */ |
||
| 463 | public function addToAnnotations(TAnnotationsType $annotations) |
||
| 468 | |||
| 469 | /** |
||
| 470 | * isset annotations |
||
| 471 | * |
||
| 472 | * @param scalar $index |
||
| 473 | * @return boolean |
||
| 474 | */ |
||
| 475 | public function issetAnnotations($index) |
||
| 479 | |||
| 480 | /** |
||
| 481 | * unset annotations |
||
| 482 | * |
||
| 483 | * @param scalar $index |
||
| 484 | * @return void |
||
| 485 | */ |
||
| 486 | public function unsetAnnotations($index) |
||
| 490 | |||
| 491 | /** |
||
| 492 | * Gets as annotations |
||
| 493 | * |
||
| 494 | * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\TAnnotationsType[] |
||
| 495 | */ |
||
| 496 | public function getAnnotations() |
||
| 500 | |||
| 501 | /** |
||
| 502 | * Sets a new annotations |
||
| 503 | * |
||
| 504 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\TAnnotationsType[] $annotations |
||
| 505 | * @return self |
||
| 506 | */ |
||
| 507 | public function setAnnotations(array $annotations) |
||
| 512 | |||
| 513 | /** |
||
| 514 | * Adds as entityContainer |
||
| 515 | * |
||
| 516 | * @return self |
||
| 517 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\EntityContainer $entityContainer |
||
| 518 | */ |
||
| 519 | public function addToEntityContainer(EntityContainer $entityContainer) |
||
| 524 | |||
| 525 | /** |
||
| 526 | * isset entityContainer |
||
| 527 | * |
||
| 528 | * @param scalar $index |
||
| 529 | * @return boolean |
||
| 530 | */ |
||
| 531 | public function issetEntityContainer($index) |
||
| 535 | |||
| 536 | /** |
||
| 537 | * unset entityContainer |
||
| 538 | * |
||
| 539 | * @param scalar $index |
||
| 540 | * @return void |
||
| 541 | */ |
||
| 542 | public function unsetEntityContainer($index) |
||
| 546 | |||
| 547 | /** |
||
| 548 | * Gets as entityContainer |
||
| 549 | * |
||
| 550 | * @return \AlgoWeb\ODataMetadata\MetadataV3\edm\EntityContainer[] |
||
| 551 | */ |
||
| 552 | public function getEntityContainer() |
||
| 556 | |||
| 557 | /** |
||
| 558 | * Sets a new entityContainer |
||
| 559 | * |
||
| 560 | * @param \AlgoWeb\ODataMetadata\MetadataV3\edm\EntityContainer[] $entityContainer |
||
| 561 | * @return self |
||
| 562 | */ |
||
| 563 | public function setEntityContainer(array $entityContainer) |
||
| 568 | |||
| 569 | |||
| 570 | public function isGSchemaBodyElementsValid(&$msg = null) |
||
| 634 | } |
||
| 635 |