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 |
||
| 17 | final class MappingException extends BaseMappingException |
||
| 18 | { |
||
| 19 | public static function typeExists(string $name) : self |
||
| 23 | |||
| 24 | public static function typeNotFound(string $name) : self |
||
| 28 | |||
| 29 | 6 | public static function mappingNotFound(string $className, string $fieldName) : self |
|
| 33 | |||
| 34 | public static function referenceMappingNotFound(string $className, string $fieldName) : self |
||
| 38 | |||
| 39 | 2 | public static function mappingNotFoundInClassNorDescendants(string $className, string $fieldName) : self |
|
| 43 | |||
| 44 | 2 | public static function referenceFieldConflict(string $fieldName, string $className, string $className2) : self |
|
| 48 | |||
| 49 | 2 | public static function mappingNotFoundByDbName(string $className, string $dbFieldName) : self |
|
| 53 | |||
| 54 | public static function duplicateFieldMapping(string $document, string $fieldName) : self |
||
| 58 | |||
| 59 | 2 | public static function duplicateDatabaseFieldName(string $document, string $offendingFieldName, string $databaseName, string $originalFieldName) : self |
|
| 63 | |||
| 64 | 2 | public static function discriminatorFieldConflict(string $document, string $fieldName) : self |
|
| 68 | |||
| 69 | public static function invalidClassInDiscriminatorMap(string $className, string $owningClass) : self |
||
| 73 | |||
| 74 | 16 | public static function unlistedClassInDiscriminatorMap(string $className) : self |
|
| 78 | |||
| 79 | public static function invalidDiscriminatorValue(string $value, string $owningClass) : self |
||
| 83 | |||
| 84 | public static function missingFieldName(string $className) : self |
||
| 88 | |||
| 89 | 4 | public static function classIsNotAValidDocument(string $className) : self |
|
| 93 | |||
| 94 | 5 | public static function classCanOnlyBeMappedByOneAbstractDocument(string $className, AbstractDocument $mappedAs, AbstractDocument $offending) : self |
|
| 103 | |||
| 104 | public static function reflectionFailure(string $document, ReflectionException $previousException) : self |
||
| 108 | |||
| 109 | public static function identifierRequired(string $documentName) : self |
||
| 113 | |||
| 114 | public static function missingIdentifierField(string $className, string $fieldName) : self |
||
| 118 | |||
| 119 | public static function missingIdGeneratorClass(string $className) : self |
||
| 123 | |||
| 124 | public static function classIsNotAValidGenerator(string $className) : self |
||
| 128 | |||
| 129 | public static function missingGeneratorSetter(string $className, string $optionName) : self |
||
| 133 | |||
| 134 | 1 | public static function cascadeOnEmbeddedNotAllowed(string $className, string $fieldName) : self |
|
| 138 | |||
| 139 | 3 | public static function simpleReferenceRequiresTargetDocument(string $className, string $fieldName) : self |
|
| 143 | |||
| 144 | 1 | public static function simpleReferenceMustNotTargetDiscriminatedDocument(string $targetDocument) : self |
|
| 148 | |||
| 149 | 1 | public static function atomicCollectionStrategyNotAllowed(string $strategy, string $className, string $fieldName) : self |
|
| 153 | |||
| 154 | 4 | public static function owningAndInverseReferencesRequireTargetDocument(string $className, string $fieldName) : self |
|
| 158 | |||
| 159 | 1 | public static function mustNotChangeIdentifierFieldsType(string $className, string $fieldName) : self |
|
| 163 | |||
| 164 | 1 | public static function referenceManySortMustNotBeUsedWithNonSetCollectionStrategy(string $className, string $fieldName, string $strategy) : self |
|
| 168 | |||
| 169 | public static function invalidStorageStrategy(string $className, string $fieldName, string $type, string $strategy) : self |
||
| 173 | |||
| 174 | 1 | public static function collectionClassDoesNotImplementCommonInterface(string $className, string $fieldName, string $collectionClass) : self |
|
| 178 | |||
| 179 | 2 | public static function shardKeyInSingleCollInheritanceSubclass(string $subclassName) : self |
|
| 183 | |||
| 184 | 2 | public static function embeddedDocumentCantHaveShardKey(string $className) : self |
|
| 188 | |||
| 189 | 1 | public static function onlySetStrategyAllowedInShardKey(string $className, string $fieldName) : self |
|
| 193 | |||
| 194 | 3 | public static function noMultiKeyShardKeys(string $className, string $fieldName) : self |
|
| 198 | |||
| 199 | public static function cannotLookupDbRefReference(string $className, string $fieldName) : self |
||
| 203 | |||
| 204 | public static function repositoryMethodLookupNotAllowed(string $className, string $fieldName) : self |
||
| 208 | |||
| 209 | 1 | public static function cannotUseShardedCollectionInOutStage(string $className) : self |
|
| 213 | |||
| 214 | 3 | public static function cannotUseShardedCollectionInLookupStages(string $className) : self |
|
| 218 | |||
| 219 | public static function referencePrimersOnlySupportedForInverseReferenceMany(string $className, string $fieldName) : self |
||
| 223 | |||
| 224 | 1 | public static function connectFromFieldMustReferenceSameDocument(string $fieldName) : self |
|
| 228 | |||
| 229 | 3 | public static function repositoryMethodCanNotBeCombinedWithSkipLimitAndSort(string $className, string $fieldName) : self |
|
| 233 | |||
| 234 | 2 | public static function xmlMappingFileInvalid(string $filename, string $errorDetails) : self |
|
| 238 | |||
| 239 | 1 | public static function fieldNotAllowedForGridFS(string $className, string $fieldName) : self |
|
| 243 | |||
| 244 | public static function discriminatorNotAllowedForGridFS(string $className) : self |
||
| 248 | |||
| 249 | public static function invalidRepositoryClass(string $className, string $repositoryClass, string $expectedRepositoryClass) : self |
||
| 258 | |||
| 259 | public static function viewWithoutRootClass(string $className) : self |
||
| 263 | |||
| 264 | public static function viewRootClassNotFound(string $className, string $rootClass) : self |
||
| 268 | } |
||
| 269 |