Complex classes like ModelManager 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 ModelManager, and based on these observations, apply Extract Interface, too.
| 1 | <?php | ||
| 27 | class ModelManager implements ModelManagerInterface | ||
| 28 | { | ||
| 29 | public const ID_SEPARATOR = '-'; | ||
| 30 | protected $registry; | ||
| 31 | |||
| 32 | public function __construct(ManagerRegistry $registry) | ||
| 36 | |||
| 37 | /** | ||
| 38 |      * {@inheritdoc} | ||
| 39 | */ | ||
| 40 | public function getMetadata($class) | ||
| 44 | |||
| 45 | /** | ||
| 46 | * Returns the model's metadata holding the fully qualified property, and the last | ||
| 47 | * property name. | ||
| 48 | * | ||
| 49 | * @param string $baseClass The base class of the model holding the fully qualified property | ||
| 50 |      * @param string $propertyFullName The name of the fully qualified property (dot ('.') separated | ||
| 51 | * property string) | ||
| 52 | * | ||
| 53 | * @return array( | ||
|  | |||
| 54 | * \Doctrine\ODM\MongoDB\Mapping\ClassMetadata $parentMetadata, | ||
| 55 | * string $lastPropertyName, | ||
| 56 | * array $parentAssociationMappings | ||
| 57 | * ) | ||
| 58 | */ | ||
| 59 | public function getParentMetadataForProperty($baseClass, $propertyFullName) | ||
| 74 | |||
| 75 | /** | ||
| 76 |      * {@inheritdoc} | ||
| 77 | */ | ||
| 78 | public function hasMetadata($class) | ||
| 82 | |||
| 83 | /** | ||
| 84 |      * {@inheritdoc} | ||
| 85 | */ | ||
| 86 | public function getNewFieldDescriptionInstance($class, $name, array $options = []) | ||
| 118 | |||
| 119 | /** | ||
| 120 |      * {@inheritdoc} | ||
| 121 | */ | ||
| 122 | public function create($object) | ||
| 128 | |||
| 129 | /** | ||
| 130 |      * {@inheritdoc} | ||
| 131 | */ | ||
| 132 | public function update($object) | ||
| 138 | |||
| 139 | /** | ||
| 140 |      * {@inheritdoc} | ||
| 141 | */ | ||
| 142 | public function delete($object) | ||
| 148 | |||
| 149 | /** | ||
| 150 |      * {@inheritdoc} | ||
| 151 | */ | ||
| 152 | public function find($class, $id) | ||
| 170 | |||
| 171 | /** | ||
| 172 |      * {@inheritdoc} | ||
| 173 | */ | ||
| 174 | public function findBy($class, array $criteria = []) | ||
| 178 | |||
| 179 | /** | ||
| 180 |      * {@inheritdoc} | ||
| 181 | */ | ||
| 182 | public function findOneBy($class, array $criteria = []) | ||
| 186 | |||
| 187 | /** | ||
| 188 | * @param string $class | ||
| 189 | * | ||
| 190 | * @throw \RuntimeException | ||
| 191 | * | ||
| 192 | * @return \Doctrine\ODM\MongoDB\DocumentManager | ||
| 193 | */ | ||
| 194 | public function getDocumentManager($class) | ||
| 208 | |||
| 209 | /** | ||
| 210 |      * {@inheritdoc} | ||
| 211 | */ | ||
| 212 | public function getParentFieldDescription($parentAssociationMapping, $class) | ||
| 226 | |||
| 227 | /** | ||
| 228 |      * {@inheritdoc} | ||
| 229 | */ | ||
| 230 | public function createQuery($class, $alias = 'o') | ||
| 236 | |||
| 237 | /** | ||
| 238 |      * {@inheritdoc} | ||
| 239 | */ | ||
| 240 | public function executeQuery($query) | ||
| 248 | |||
| 249 | /** | ||
| 250 |      * {@inheritdoc} | ||
| 251 | */ | ||
| 252 | public function getModelIdentifier($class) | ||
| 256 | |||
| 257 | /** | ||
| 258 |      * {@inheritdoc} | ||
| 259 | */ | ||
| 260 | public function getIdentifierValues($document) | ||
| 264 | |||
| 265 | /** | ||
| 266 |      * {@inheritdoc} | ||
| 267 | */ | ||
| 268 | public function getIdentifierFieldNames($class) | ||
| 272 | |||
| 273 | /** | ||
| 274 |      * {@inheritdoc} | ||
| 275 | */ | ||
| 276 | public function getNormalizedIdentifier($document) | ||
| 291 | |||
| 292 | /** | ||
| 293 |      * {@inheritdoc} | ||
| 294 | */ | ||
| 295 | public function getUrlsafeIdentifier($entity) | ||
| 299 | |||
| 300 | /** | ||
| 301 |      * {@inheritdoc} | ||
| 302 | */ | ||
| 303 | public function addIdentifiersToQuery($class, ProxyQueryInterface $queryProxy, array $idx) | ||
| 308 | |||
| 309 | /** | ||
| 310 |      * {@inheritdoc} | ||
| 311 | */ | ||
| 312 | public function batchDelete($class, ProxyQueryInterface $queryProxy) | ||
| 332 | |||
| 333 | /** | ||
| 334 |      * {@inheritdoc} | ||
| 335 | */ | ||
| 336 | public function getDataSourceIterator(DatagridInterface $datagrid, array $fields, $firstResult = null, $maxResult = null) | ||
| 346 | |||
| 347 | /** | ||
| 348 |      * {@inheritdoc} | ||
| 349 | */ | ||
| 350 | public function getExportFields($class) | ||
| 356 | |||
| 357 | /** | ||
| 358 |      * {@inheritdoc} | ||
| 359 | */ | ||
| 360 | public function getModelInstance($class) | ||
| 364 | |||
| 365 | /** | ||
| 366 |      * {@inheritdoc} | ||
| 367 | */ | ||
| 368 | public function getSortParameters(FieldDescriptionInterface $fieldDescription, DatagridInterface $datagrid) | ||
| 389 | |||
| 390 | /** | ||
| 391 |      * {@inheritdoc} | ||
| 392 | */ | ||
| 393 | public function getPaginationParameters(DatagridInterface $datagrid, $page) | ||
| 404 | |||
| 405 | /** | ||
| 406 |      * {@inheritdoc} | ||
| 407 | */ | ||
| 408 | public function getDefaultSortValues($class) | ||
| 417 | |||
| 418 | /** | ||
| 419 |      * {@inheritdoc} | ||
| 420 | */ | ||
| 421 | public function modelTransform($class, $instance) | ||
| 425 | |||
| 426 | /** | ||
| 427 |      * {@inheritdoc} | ||
| 428 | */ | ||
| 429 | public function modelReverseTransform($class, array $array = []) | ||
| 471 | |||
| 472 | /** | ||
| 473 |      * {@inheritdoc} | ||
| 474 | */ | ||
| 475 | public function getModelCollectionInstance($class) | ||
| 479 | |||
| 480 | /** | ||
| 481 |      * {@inheritdoc} | ||
| 482 | */ | ||
| 483 | public function collectionClear(&$collection) | ||
| 487 | |||
| 488 | /** | ||
| 489 |      * {@inheritdoc} | ||
| 490 | */ | ||
| 491 | public function collectionHasElement(&$collection, &$element) | ||
| 495 | |||
| 496 | /** | ||
| 497 |      * {@inheritdoc} | ||
| 498 | */ | ||
| 499 | public function collectionAddElement(&$collection, &$element) | ||
| 503 | |||
| 504 | /** | ||
| 505 |      * {@inheritdoc} | ||
| 506 | */ | ||
| 507 | public function collectionRemoveElement(&$collection, &$element) | ||
| 511 | |||
| 512 | /** | ||
| 513 | * method taken from PropertyPath. | ||
| 514 | * | ||
| 515 | * @param string $property | ||
| 516 | * | ||
| 517 | * @return mixed | ||
| 518 | */ | ||
| 519 | protected function camelize($property) | ||
| 523 | } | ||
| 524 | 
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.