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 | 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 | 1 | 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 | public static function invalidDiscriminatorValue(string $value, string $owningClass) : self |
||
78 | |||
79 | public static function missingFieldName(string $className) : self |
||
83 | |||
84 | 3 | public static function classIsNotAValidDocument(string $className) : self |
|
88 | |||
89 | 5 | public static function classCanOnlyBeMappedByOneAbstractDocument(string $className, AbstractDocument $mappedAs, AbstractDocument $offending) : self |
|
98 | |||
99 | public static function reflectionFailure(string $document, ReflectionException $previousException) : self |
||
103 | |||
104 | public static function identifierRequired(string $documentName) : self |
||
108 | |||
109 | public static function missingIdentifierField(string $className, string $fieldName) : self |
||
113 | |||
114 | public static function missingIdGeneratorClass(string $className) : self |
||
118 | |||
119 | public static function classIsNotAValidGenerator(string $className) : self |
||
123 | |||
124 | public static function missingGeneratorSetter(string $className, string $optionName) : self |
||
128 | |||
129 | 1 | public static function cascadeOnEmbeddedNotAllowed(string $className, string $fieldName) : self |
|
133 | |||
134 | 3 | public static function simpleReferenceRequiresTargetDocument(string $className, string $fieldName) : self |
|
138 | |||
139 | 1 | public static function simpleReferenceMustNotTargetDiscriminatedDocument(string $targetDocument) : self |
|
143 | |||
144 | 1 | public static function atomicCollectionStrategyNotAllowed(string $strategy, string $className, string $fieldName) : self |
|
148 | |||
149 | 4 | public static function owningAndInverseReferencesRequireTargetDocument(string $className, string $fieldName) : self |
|
153 | |||
154 | 1 | public static function mustNotChangeIdentifierFieldsType(string $className, string $fieldName) : self |
|
158 | |||
159 | 1 | public static function referenceManySortMustNotBeUsedWithNonSetCollectionStrategy(string $className, string $fieldName, string $strategy) : self |
|
163 | |||
164 | public static function invalidStorageStrategy(string $className, string $fieldName, string $type, string $strategy) : self |
||
168 | |||
169 | 1 | public static function collectionClassDoesNotImplementCommonInterface(string $className, string $fieldName, string $collectionClass) : self |
|
173 | |||
174 | 2 | public static function shardKeyInSingleCollInheritanceSubclass(string $subclassName) : self |
|
178 | |||
179 | 2 | public static function embeddedDocumentCantHaveShardKey(string $className) : self |
|
183 | |||
184 | 1 | public static function onlySetStrategyAllowedInShardKey(string $className, string $fieldName) : self |
|
188 | |||
189 | 3 | public static function noMultiKeyShardKeys(string $className, string $fieldName) : self |
|
193 | |||
194 | public static function cannotLookupDbRefReference(string $className, string $fieldName) : self |
||
198 | |||
199 | public static function repositoryMethodLookupNotAllowed(string $className, string $fieldName) : self |
||
203 | |||
204 | 1 | public static function cannotUseShardedCollectionInOutStage(string $className) : self |
|
208 | |||
209 | 3 | public static function cannotUseShardedCollectionInLookupStages(string $className) : self |
|
213 | |||
214 | public static function referencePrimersOnlySupportedForInverseReferenceMany(string $className, string $fieldName) : self |
||
218 | |||
219 | 1 | public static function connectFromFieldMustReferenceSameDocument(string $fieldName) : self |
|
223 | |||
224 | 3 | public static function repositoryMethodCanNotBeCombinedWithSkipLimitAndSort(string $className, string $fieldName) : self |
|
228 | |||
229 | 2 | public static function xmlMappingFileInvalid(string $filename, string $errorDetails) : self |
|
233 | |||
234 | 1 | public static function fieldNotAllowedForGridFS(string $className, string $fieldName) : self |
|
238 | |||
239 | public static function discriminatorNotAllowedForGridFS(string $className) : self |
||
243 | } |
||
244 |