Complex classes like MappingException 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 MappingException, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 15 | class MappingException extends BaseMappingException |
||
| 16 | { |
||
| 17 | public static function typeExists(string $name) : self |
||
| 21 | |||
| 22 | public static function typeNotFound(string $name) : self |
||
| 26 | |||
| 27 | 6 | public static function mappingNotFound(string $className, string $fieldName) : self |
|
| 31 | |||
| 32 | public static function referenceMappingNotFound(string $className, string $fieldName) : self |
||
| 36 | |||
| 37 | 2 | public static function mappingNotFoundInClassNorDescendants(string $className, string $fieldName) : self |
|
| 41 | |||
| 42 | 2 | public static function referenceFieldConflict(string $fieldName, string $className, string $className2) : self |
|
| 46 | |||
| 47 | 1 | public static function mappingNotFoundByDbName(string $className, string $dbFieldName) : self |
|
| 51 | |||
| 52 | public static function duplicateFieldMapping(string $document, string $fieldName) : self |
||
| 56 | |||
| 57 | 2 | public static function discriminatorFieldConflict(string $document, string $fieldName) : self |
|
| 61 | |||
| 62 | public static function invalidClassInDiscriminatorMap(string $className, string $owningClass) : self |
||
| 66 | |||
| 67 | 14 | public static function unlistedClassInDiscriminatorMap(string $className) : self |
|
| 71 | |||
| 72 | public static function invalidDiscriminatorValue(string $value, string $owningClass) : self |
||
| 76 | |||
| 77 | public static function missingFieldName(string $className) : self |
||
| 81 | |||
| 82 | 3 | public static function classIsNotAValidDocument(string $className) : self |
|
| 86 | |||
| 87 | public static function reflectionFailure(string $document, ReflectionException $previousException) : self |
||
| 91 | |||
| 92 | public static function identifierRequired(string $documentName) : self |
||
| 96 | |||
| 97 | public static function missingIdentifierField(string $className, string $fieldName) : self |
||
| 101 | |||
| 102 | public static function missingIdGeneratorClass(string $className) : self |
||
| 106 | |||
| 107 | public static function classIsNotAValidGenerator(string $className) : self |
||
| 111 | |||
| 112 | public static function missingGeneratorSetter(string $className, string $optionName) : self |
||
| 116 | |||
| 117 | 1 | public static function cascadeOnEmbeddedNotAllowed(string $className, string $fieldName) : self |
|
| 121 | |||
| 122 | 3 | public static function simpleReferenceRequiresTargetDocument(string $className, string $fieldName) : self |
|
| 126 | |||
| 127 | 1 | public static function simpleReferenceMustNotTargetDiscriminatedDocument(string $targetDocument) : self |
|
| 131 | |||
| 132 | 1 | public static function atomicCollectionStrategyNotAllowed(string $strategy, string $className, string $fieldName) : self |
|
| 136 | |||
| 137 | 4 | public static function owningAndInverseReferencesRequireTargetDocument(string $className, string $fieldName) : self |
|
| 141 | |||
| 142 | 1 | public static function mustNotChangeIdentifierFieldsType(string $className, string $fieldName) : self |
|
| 146 | |||
| 147 | 1 | public static function referenceManySortMustNotBeUsedWithNonSetCollectionStrategy(string $className, string $fieldName, string $strategy) : self |
|
| 151 | |||
| 152 | public static function invalidStorageStrategy(string $className, string $fieldName, string $type, string $strategy) : self |
||
| 156 | |||
| 157 | 1 | public static function collectionClassDoesNotImplementCommonInterface(string $className, string $fieldName, string $collectionClass) : self |
|
| 161 | |||
| 162 | 2 | public static function shardKeyInSingleCollInheritanceSubclass(string $subclassName) : self |
|
| 166 | |||
| 167 | 2 | public static function embeddedDocumentCantHaveShardKey(string $className) : self |
|
| 171 | |||
| 172 | 1 | public static function onlySetStrategyAllowedInShardKey(string $className, string $fieldName) : self |
|
| 176 | |||
| 177 | 3 | public static function noMultiKeyShardKeys(string $className, string $fieldName) : self |
|
| 181 | |||
| 182 | public static function cannotLookupDbRefReference(string $className, string $fieldName) : self |
||
| 186 | |||
| 187 | public static function repositoryMethodLookupNotAllowed(string $className, string $fieldName) : self |
||
| 191 | |||
| 192 | 1 | public static function cannotUseShardedCollectionInOutStage(string $className) : self |
|
| 196 | |||
| 197 | 3 | public static function cannotUseShardedCollectionInLookupStages(string $className) : self |
|
| 201 | |||
| 202 | public static function referencePrimersOnlySupportedForInverseReferenceMany(string $className, string $fieldName) : self |
||
| 206 | |||
| 207 | 1 | public static function connectFromFieldMustReferenceSameDocument(string $fieldName) : self |
|
| 211 | |||
| 212 | 3 | public static function repositoryMethodCanNotBeCombinedWithSkipLimitAndSort(string $className, string $fieldName) : self |
|
| 216 | |||
| 217 | 2 | public static function xmlMappingFileInvalid(string $filename, string $errorDetails) : self |
|
| 221 | |||
| 222 | 1 | public static function fieldNotAllowedForGridFS(string $className, string $fieldName) : self |
|
| 226 | |||
| 227 | public static function discriminatorNotAllowedForGridFS(string $className) : self |
||
| 231 | } |
||
| 232 |