Complex classes like AbstractTypeDefinition 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 AbstractTypeDefinition, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 22 | abstract class AbstractTypeDefinition extends AbstractExtensionData implements TypeDefinitionInterface |
||
| 23 | { |
||
| 24 | /** |
||
| 25 | * @var string |
||
| 26 | */ |
||
| 27 | protected $id; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @var string |
||
| 31 | */ |
||
| 32 | protected $localName; |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @var string |
||
| 36 | */ |
||
| 37 | protected $localNamespace; |
||
| 38 | |||
| 39 | /** |
||
| 40 | * @var string |
||
| 41 | */ |
||
| 42 | protected $queryName; |
||
| 43 | |||
| 44 | /** |
||
| 45 | * @var string |
||
| 46 | */ |
||
| 47 | protected $displayName; |
||
| 48 | |||
| 49 | /** |
||
| 50 | * @var string |
||
| 51 | */ |
||
| 52 | protected $description; |
||
| 53 | |||
| 54 | /** |
||
| 55 | * @var BaseTypeId |
||
| 56 | */ |
||
| 57 | protected $baseTypeId; |
||
| 58 | |||
| 59 | /** |
||
| 60 | * @var string |
||
| 61 | */ |
||
| 62 | protected $parentTypeId; |
||
| 63 | |||
| 64 | /** |
||
| 65 | * @var boolean|null |
||
| 66 | */ |
||
| 67 | protected $isCreatable; |
||
| 68 | |||
| 69 | /** |
||
| 70 | * @var boolean|null |
||
| 71 | */ |
||
| 72 | protected $isFileable; |
||
| 73 | |||
| 74 | /** |
||
| 75 | * @var boolean|null |
||
| 76 | */ |
||
| 77 | protected $isQueryable; |
||
| 78 | |||
| 79 | /** |
||
| 80 | * @var boolean|null |
||
| 81 | */ |
||
| 82 | protected $isIncludedInSupertypeQuery; |
||
| 83 | |||
| 84 | /** |
||
| 85 | * @var boolean|null |
||
| 86 | */ |
||
| 87 | protected $isFulltextIndexed; |
||
| 88 | |||
| 89 | /** |
||
| 90 | * @var boolean|null |
||
| 91 | */ |
||
| 92 | protected $isControllableAcl; |
||
| 93 | |||
| 94 | /** |
||
| 95 | * @var boolean|null |
||
| 96 | */ |
||
| 97 | protected $isControllablePolicy; |
||
| 98 | |||
| 99 | /** |
||
| 100 | * @var PropertyDefinitionInterface[] |
||
| 101 | */ |
||
| 102 | protected $propertyDefinitions = []; |
||
| 103 | |||
| 104 | /** |
||
| 105 | * @var TypeMutabilityInterface |
||
| 106 | */ |
||
| 107 | protected $typeMutability; |
||
| 108 | |||
| 109 | /** |
||
| 110 | * @param string $id The type definition id |
||
| 111 | * @throws CmisInvalidArgumentException Exception is thrown if an empty <code>$id</code> is given |
||
| 112 | */ |
||
| 113 | 242 | public function __construct($id) |
|
| 120 | |||
| 121 | /** |
||
| 122 | * Returns the type ID. |
||
| 123 | * |
||
| 124 | * @return string |
||
| 125 | */ |
||
| 126 | 27 | public function getId() |
|
| 130 | |||
| 131 | /** |
||
| 132 | * @param string $id |
||
| 133 | */ |
||
| 134 | 242 | public function setId($id) |
|
| 138 | |||
| 139 | /** |
||
| 140 | * Returns the local name. |
||
| 141 | * |
||
| 142 | * @return string |
||
| 143 | */ |
||
| 144 | 29 | public function getLocalName() |
|
| 148 | |||
| 149 | /** |
||
| 150 | * @param string $localName |
||
| 151 | */ |
||
| 152 | 36 | public function setLocalName($localName) |
|
| 156 | |||
| 157 | /** |
||
| 158 | * Returns the local namespace. |
||
| 159 | * |
||
| 160 | * @return string |
||
| 161 | */ |
||
| 162 | 29 | public function getLocalNamespace() |
|
| 166 | |||
| 167 | /** |
||
| 168 | * @param string $localNamespace |
||
| 169 | */ |
||
| 170 | 36 | public function setLocalNamespace($localNamespace) |
|
| 174 | |||
| 175 | /** |
||
| 176 | * Returns the query name |
||
| 177 | * |
||
| 178 | * @return string |
||
| 179 | */ |
||
| 180 | 33 | public function getQueryName() |
|
| 184 | |||
| 185 | /** |
||
| 186 | * @param string $queryName |
||
| 187 | */ |
||
| 188 | 36 | public function setQueryName($queryName) |
|
| 192 | |||
| 193 | /** |
||
| 194 | * Returns the display name. |
||
| 195 | * |
||
| 196 | * @return string |
||
| 197 | */ |
||
| 198 | 29 | public function getDisplayName() |
|
| 202 | |||
| 203 | /** |
||
| 204 | * @param string $displayName |
||
| 205 | */ |
||
| 206 | 36 | public function setDisplayName($displayName) |
|
| 210 | |||
| 211 | /** |
||
| 212 | * Returns the property description. |
||
| 213 | * |
||
| 214 | * @return string |
||
| 215 | */ |
||
| 216 | 29 | public function getDescription() |
|
| 220 | |||
| 221 | /** |
||
| 222 | * @param string $description |
||
| 223 | */ |
||
| 224 | 36 | public function setDescription($description) |
|
| 228 | |||
| 229 | /** |
||
| 230 | * Returns the base object type ID. |
||
| 231 | * |
||
| 232 | * @return BaseTypeId |
||
| 233 | */ |
||
| 234 | 23 | public function getBaseTypeId() |
|
| 238 | |||
| 239 | /** |
||
| 240 | * @param BaseTypeId $baseTypeId |
||
| 241 | */ |
||
| 242 | 3 | public function setBaseTypeId(BaseTypeId $baseTypeId) |
|
| 246 | |||
| 247 | /** |
||
| 248 | * Returns the parent type ID. |
||
| 249 | * |
||
| 250 | * @return string |
||
| 251 | */ |
||
| 252 | 29 | public function getParentTypeId() |
|
| 256 | |||
| 257 | /** |
||
| 258 | * @param string $parentTypeId |
||
| 259 | */ |
||
| 260 | 36 | public function setParentTypeId($parentTypeId) |
|
| 264 | |||
| 265 | /** |
||
| 266 | * Returns if an object of this type can be created. |
||
| 267 | * |
||
| 268 | * @return boolean |
||
| 269 | */ |
||
| 270 | 30 | public function isCreatable() |
|
| 274 | |||
| 275 | /** |
||
| 276 | * @param boolean $isCreatable |
||
| 277 | */ |
||
| 278 | 38 | public function setIsCreatable($isCreatable) |
|
| 282 | |||
| 283 | /** |
||
| 284 | * Returns if an object of this type can be filed. |
||
| 285 | * |
||
| 286 | * @return boolean |
||
| 287 | */ |
||
| 288 | 30 | public function isFileable() |
|
| 292 | |||
| 293 | /** |
||
| 294 | * @param boolean $isFileable |
||
| 295 | */ |
||
| 296 | 38 | public function setIsFileable($isFileable) |
|
| 300 | |||
| 301 | /** |
||
| 302 | * Returns if this type is queryable. |
||
| 303 | * |
||
| 304 | * @return boolean |
||
| 305 | */ |
||
| 306 | 30 | public function isQueryable() |
|
| 310 | |||
| 311 | /** |
||
| 312 | * @param boolean $isQueryable |
||
| 313 | */ |
||
| 314 | 38 | public function setIsQueryable($isQueryable) |
|
| 318 | |||
| 319 | /** |
||
| 320 | * Returns if this type is included in queries that query the super type. |
||
| 321 | * |
||
| 322 | * @return boolean |
||
| 323 | */ |
||
| 324 | 30 | public function isIncludedInSupertypeQuery() |
|
| 328 | |||
| 329 | /** |
||
| 330 | * @param boolean $isIncludedInSupertypeQuery |
||
| 331 | */ |
||
| 332 | 38 | public function setIsIncludedInSupertypeQuery($isIncludedInSupertypeQuery) |
|
| 336 | |||
| 337 | /** |
||
| 338 | * Returns if this type is full text indexed. |
||
| 339 | * |
||
| 340 | * @return boolean |
||
| 341 | */ |
||
| 342 | 30 | public function isFulltextIndexed() |
|
| 346 | |||
| 347 | /** |
||
| 348 | * Sets if this type is full text indexed. |
||
| 349 | * |
||
| 350 | * @param boolean $isFulltextIndexed |
||
| 351 | */ |
||
| 352 | 38 | public function setIsFulltextIndexed($isFulltextIndexed) |
|
| 356 | |||
| 357 | /** |
||
| 358 | * @return boolean |
||
| 359 | */ |
||
| 360 | 30 | public function isControllableAcl() |
|
| 364 | |||
| 365 | /** |
||
| 366 | * @param boolean $isControllableAcl |
||
| 367 | */ |
||
| 368 | 38 | public function setIsControllableAcl($isControllableAcl) |
|
| 372 | |||
| 373 | /** |
||
| 374 | * Returns if objects of this type are controllable by policies. |
||
| 375 | */ |
||
| 376 | 30 | public function isControllablePolicy() |
|
| 380 | |||
| 381 | /** |
||
| 382 | * @param boolean $isControllablePolicy |
||
| 383 | */ |
||
| 384 | 38 | public function setIsControllablePolicy($isControllablePolicy) |
|
| 388 | |||
| 389 | /** |
||
| 390 | * Returns the property definitions for the given id of this type. |
||
| 391 | * |
||
| 392 | * @param string $id id of the property |
||
| 393 | * @return PropertyDefinitionInterface|null the property definition |
||
| 394 | */ |
||
| 395 | 2 | public function getPropertyDefinition($id) |
|
| 399 | |||
| 400 | /** |
||
| 401 | * Returns the property definitions of this type. |
||
| 402 | * |
||
| 403 | * @return PropertyDefinitionInterface[] the property definitions |
||
| 404 | */ |
||
| 405 | 23 | public function getPropertyDefinitions() |
|
| 409 | |||
| 410 | /** |
||
| 411 | * @param PropertyDefinitionInterface[] $propertyDefinitions |
||
| 412 | */ |
||
| 413 | 24 | public function setPropertyDefinitions(array $propertyDefinitions) |
|
| 419 | |||
| 420 | /** |
||
| 421 | * @param PropertyDefinitionInterface $propertyDefinition |
||
| 422 | */ |
||
| 423 | 4 | public function addPropertyDefinition(PropertyDefinitionInterface $propertyDefinition) |
|
| 427 | |||
| 428 | /** |
||
| 429 | * Returns type mutability flags. |
||
| 430 | * |
||
| 431 | * @return TypeMutabilityInterface |
||
| 432 | */ |
||
| 433 | 23 | public function getTypeMutability() |
|
| 437 | |||
| 438 | /** |
||
| 439 | * @param TypeMutabilityInterface $typeMutability |
||
| 440 | */ |
||
| 441 | 3 | public function setTypeMutability(TypeMutabilityInterface $typeMutability) |
|
| 445 | } |
||
| 446 |