Complex classes like Configuration 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 Configuration, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 50 | class Configuration extends \Doctrine\MongoDB\Configuration |
||
| 51 | { |
||
| 52 | /** |
||
| 53 | * Never autogenerate a proxy/hydrator/persistent collection and rely that |
||
| 54 | * it was generated by some process before deployment. Copied from |
||
| 55 | * \Doctrine\Common\Proxy\AbstractProxyFactory. |
||
| 56 | * |
||
| 57 | * @var integer |
||
| 58 | */ |
||
| 59 | const AUTOGENERATE_NEVER = 0; |
||
| 60 | |||
| 61 | /** |
||
| 62 | * Always generates a new proxy/hydrator/persistent collection in every request. |
||
| 63 | * |
||
| 64 | * This is only sane during development. |
||
| 65 | * Copied from \Doctrine\Common\Proxy\AbstractProxyFactory. |
||
| 66 | * |
||
| 67 | * @var integer |
||
| 68 | */ |
||
| 69 | const AUTOGENERATE_ALWAYS = 1; |
||
| 70 | |||
| 71 | /** |
||
| 72 | * Autogenerate the proxy/hydrator/persistent collection class when the file does not exist. |
||
| 73 | * |
||
| 74 | * This strategy causes a file exists call whenever any proxy/hydrator is used the |
||
| 75 | * first time in a request. Copied from \Doctrine\Common\Proxy\AbstractProxyFactory. |
||
| 76 | * |
||
| 77 | * @var integer |
||
| 78 | */ |
||
| 79 | const AUTOGENERATE_FILE_NOT_EXISTS = 2; |
||
| 80 | |||
| 81 | /** |
||
| 82 | * Generate the proxy/hydrator/persistent collection classes using eval(). |
||
| 83 | * |
||
| 84 | * This strategy is only sane for development. |
||
| 85 | * Copied from \Doctrine\Common\Proxy\AbstractProxyFactory. |
||
| 86 | * |
||
| 87 | * @var integer |
||
| 88 | */ |
||
| 89 | const AUTOGENERATE_EVAL = 3; |
||
| 90 | |||
| 91 | /** |
||
| 92 | * Adds a namespace under a certain alias. |
||
| 93 | * |
||
| 94 | * @param string $alias |
||
| 95 | * @param string $namespace |
||
| 96 | */ |
||
| 97 | public function addDocumentNamespace($alias, $namespace) |
||
| 101 | |||
| 102 | /** |
||
| 103 | * Resolves a registered namespace alias to the full namespace. |
||
| 104 | * |
||
| 105 | * @param string $documentNamespaceAlias |
||
| 106 | * @return string |
||
| 107 | * @throws MongoDBException |
||
| 108 | */ |
||
| 109 | public function getDocumentNamespace($documentNamespaceAlias) |
||
| 117 | |||
| 118 | /** |
||
| 119 | * Retrieves the list of registered document namespace aliases. |
||
| 120 | * |
||
| 121 | * @return array |
||
| 122 | */ |
||
| 123 | public function getDocumentNamespaces() |
||
| 127 | |||
| 128 | /** |
||
| 129 | * Set the document alias map |
||
| 130 | * |
||
| 131 | * @param array $documentNamespaces |
||
| 132 | * @return void |
||
| 133 | */ |
||
| 134 | public function setDocumentNamespaces(array $documentNamespaces) |
||
| 138 | |||
| 139 | /** |
||
| 140 | * Sets the cache driver implementation that is used for metadata caching. |
||
| 141 | * |
||
| 142 | * @param MappingDriver $driverImpl |
||
| 143 | * @todo Force parameter to be a Closure to ensure lazy evaluation |
||
| 144 | * (as soon as a metadata cache is in effect, the driver never needs to initialize). |
||
| 145 | */ |
||
| 146 | 949 | public function setMetadataDriverImpl(MappingDriver $driverImpl) |
|
| 150 | |||
| 151 | /** |
||
| 152 | * Add a new default annotation driver with a correctly configured annotation reader. |
||
| 153 | * |
||
| 154 | * @param array $paths |
||
| 155 | * @return Mapping\Driver\AnnotationDriver |
||
| 156 | */ |
||
| 157 | public function newDefaultAnnotationDriver($paths = array()) |
||
| 163 | |||
| 164 | /** |
||
| 165 | * Gets the cache driver implementation that is used for the mapping metadata. |
||
| 166 | * |
||
| 167 | * @return MappingDriver |
||
| 168 | */ |
||
| 169 | 761 | public function getMetadataDriverImpl() |
|
| 174 | |||
| 175 | /** |
||
| 176 | * Gets the cache driver implementation that is used for metadata caching. |
||
| 177 | * |
||
| 178 | * @return \Doctrine\Common\Cache\Cache |
||
| 179 | */ |
||
| 180 | 933 | public function getMetadataCacheImpl() |
|
| 185 | |||
| 186 | /** |
||
| 187 | * Sets the cache driver implementation that is used for metadata caching. |
||
| 188 | * |
||
| 189 | * @param \Doctrine\Common\Cache\Cache $cacheImpl |
||
| 190 | */ |
||
| 191 | public function setMetadataCacheImpl(Cache $cacheImpl) |
||
| 195 | |||
| 196 | /** |
||
| 197 | * Sets the directory where Doctrine generates any necessary proxy class files. |
||
| 198 | * |
||
| 199 | * @param string $dir |
||
| 200 | */ |
||
| 201 | 933 | public function setProxyDir($dir) |
|
| 205 | |||
| 206 | /** |
||
| 207 | * Gets the directory where Doctrine generates any necessary proxy class files. |
||
| 208 | * |
||
| 209 | * @return string |
||
| 210 | */ |
||
| 211 | 933 | public function getProxyDir() |
|
| 216 | |||
| 217 | /** |
||
| 218 | * Gets a boolean flag that indicates whether proxy classes should always be regenerated |
||
| 219 | * during each script execution. |
||
| 220 | * |
||
| 221 | * @return boolean|integer |
||
| 222 | */ |
||
| 223 | 933 | public function getAutoGenerateProxyClasses() |
|
| 228 | |||
| 229 | /** |
||
| 230 | * Sets a boolean flag that indicates whether proxy classes should always be regenerated |
||
| 231 | * during each script execution. |
||
| 232 | * |
||
| 233 | * @param boolean|int $bool Possible values are constants of Doctrine\Common\Proxy\AbstractProxyFactory |
||
| 234 | */ |
||
| 235 | public function setAutoGenerateProxyClasses($bool) |
||
| 239 | |||
| 240 | /** |
||
| 241 | * Gets the namespace where proxy classes reside. |
||
| 242 | * |
||
| 243 | * @return string |
||
| 244 | */ |
||
| 245 | 933 | public function getProxyNamespace() |
|
| 250 | |||
| 251 | /** |
||
| 252 | * Sets the namespace where proxy classes reside. |
||
| 253 | * |
||
| 254 | * @param string $ns |
||
| 255 | */ |
||
| 256 | 933 | public function setProxyNamespace($ns) |
|
| 260 | |||
| 261 | /** |
||
| 262 | * Sets the directory where Doctrine generates hydrator class files. |
||
| 263 | * |
||
| 264 | * @param string $dir |
||
| 265 | */ |
||
| 266 | 933 | public function setHydratorDir($dir) |
|
| 270 | |||
| 271 | /** |
||
| 272 | * Gets the directory where Doctrine generates hydrator class files. |
||
| 273 | * |
||
| 274 | * @return string |
||
| 275 | */ |
||
| 276 | 933 | public function getHydratorDir() |
|
| 281 | |||
| 282 | /** |
||
| 283 | * Gets a boolean flag that indicates whether hydrator classes should always be regenerated |
||
| 284 | * during each script execution. |
||
| 285 | * |
||
| 286 | * @return boolean|integer Possible values are defined constants |
||
| 287 | */ |
||
| 288 | 933 | public function getAutoGenerateHydratorClasses() |
|
| 293 | |||
| 294 | /** |
||
| 295 | * Sets a boolean flag that indicates whether hydrator classes should always be regenerated |
||
| 296 | * during each script execution. |
||
| 297 | * |
||
| 298 | * @param boolean|integer $bool |
||
| 299 | */ |
||
| 300 | public function setAutoGenerateHydratorClasses($bool) |
||
| 304 | |||
| 305 | /** |
||
| 306 | * Gets the namespace where hydrator classes reside. |
||
| 307 | * |
||
| 308 | * @return string |
||
| 309 | */ |
||
| 310 | 933 | public function getHydratorNamespace() |
|
| 315 | |||
| 316 | /** |
||
| 317 | * Sets the namespace where hydrator classes reside. |
||
| 318 | * |
||
| 319 | * @param string $ns |
||
| 320 | */ |
||
| 321 | 933 | public function setHydratorNamespace($ns) |
|
| 325 | |||
| 326 | /** |
||
| 327 | * Sets the directory where Doctrine generates persistent collection class files. |
||
| 328 | * |
||
| 329 | * @param string $dir |
||
| 330 | */ |
||
| 331 | 933 | public function setPersistentCollectionDir($dir) |
|
| 335 | |||
| 336 | /** |
||
| 337 | * Gets the directory where Doctrine generates persistent collection class files. |
||
| 338 | * |
||
| 339 | * @return string |
||
| 340 | */ |
||
| 341 | public function getPersistentCollectionDir() |
||
| 346 | |||
| 347 | /** |
||
| 348 | * Gets a integer flag that indicates how and when persistent collection |
||
| 349 | * classes should be generated. |
||
| 350 | * |
||
| 351 | * @return integer Possible values are defined constants |
||
| 352 | */ |
||
| 353 | 4 | public function getAutoGeneratePersistentCollectionClasses() |
|
| 358 | |||
| 359 | /** |
||
| 360 | * Sets a integer flag that indicates how and when persistent collection |
||
| 361 | * classes should be generated. |
||
| 362 | * |
||
| 363 | * @param integer $mode Possible values are defined constants |
||
| 364 | */ |
||
| 365 | public function setAutoGeneratePersistentCollectionClasses($mode) |
||
| 369 | |||
| 370 | /** |
||
| 371 | * Gets the namespace where persistent collection classes reside. |
||
| 372 | * |
||
| 373 | * @return string |
||
| 374 | */ |
||
| 375 | public function getPersistentCollectionNamespace() |
||
| 380 | |||
| 381 | /** |
||
| 382 | * Sets the namespace where persistent collection classes reside. |
||
| 383 | * |
||
| 384 | * @param string $ns |
||
| 385 | */ |
||
| 386 | 933 | public function setPersistentCollectionNamespace($ns) |
|
| 390 | |||
| 391 | /** |
||
| 392 | * Sets the default DB to use for all Documents that do not specify |
||
| 393 | * a database. |
||
| 394 | * |
||
| 395 | * @param string $defaultDB |
||
| 396 | */ |
||
| 397 | 933 | public function setDefaultDB($defaultDB) |
|
| 401 | |||
| 402 | /** |
||
| 403 | * Gets the default DB to use for all Documents that do not specify a database. |
||
| 404 | * |
||
| 405 | * @return string $defaultDB |
||
| 406 | */ |
||
| 407 | 682 | public function getDefaultDB() |
|
| 412 | |||
| 413 | /** |
||
| 414 | * Set the class metadata factory class name. |
||
| 415 | * |
||
| 416 | * @param string $cmfName |
||
| 417 | */ |
||
| 418 | public function setClassMetadataFactoryName($cmfName) |
||
| 422 | |||
| 423 | /** |
||
| 424 | * Gets the class metadata factory class name. |
||
| 425 | * |
||
| 426 | * @return string |
||
| 427 | */ |
||
| 428 | 933 | public function getClassMetadataFactoryName() |
|
| 435 | |||
| 436 | /** |
||
| 437 | * Gets array of default commit options. |
||
| 438 | * |
||
| 439 | * @return array |
||
| 440 | */ |
||
| 441 | 560 | public function getDefaultCommitOptions() |
|
| 449 | |||
| 450 | /** |
||
| 451 | * Sets array of default commit options. |
||
| 452 | * |
||
| 453 | * @param boolean $defaultCommitOptions |
||
| 454 | */ |
||
| 455 | public function setDefaultCommitOptions($defaultCommitOptions) |
||
| 459 | |||
| 460 | /** |
||
| 461 | * Add a filter to the list of possible filters. |
||
| 462 | * |
||
| 463 | * @param string $name The name of the filter. |
||
| 464 | * @param string $className The class name of the filter. |
||
| 465 | * @param array $parameters The parameters for the filter. |
||
| 466 | */ |
||
| 467 | 933 | public function addFilter($name, $className, array $parameters = array()) |
|
| 474 | |||
| 475 | /** |
||
| 476 | * Gets the class name for a given filter name. |
||
| 477 | * |
||
| 478 | * @param string $name The name of the filter. |
||
| 479 | * |
||
| 480 | * @return string|null The filter class name, or null if it is undefined |
||
| 481 | */ |
||
| 482 | 22 | public function getFilterClassName($name) |
|
| 488 | |||
| 489 | /** |
||
| 490 | * Gets the parameters for a given filter name. |
||
| 491 | * |
||
| 492 | * @param string $name The name of the filter. |
||
| 493 | * |
||
| 494 | * @return array|null The filter parameters, or null if it is undefined |
||
| 495 | */ |
||
| 496 | 21 | public function getFilterParameters($name) |
|
| 502 | |||
| 503 | /** |
||
| 504 | * Sets default repository class. |
||
| 505 | * |
||
| 506 | * @param string $className |
||
| 507 | * |
||
| 508 | * @return void |
||
| 509 | * |
||
| 510 | * @throws MongoDBException If not is a ObjectRepository |
||
| 511 | */ |
||
| 512 | public function setDefaultRepositoryClassName($className) |
||
| 522 | |||
| 523 | /** |
||
| 524 | * Get default repository class. |
||
| 525 | * |
||
| 526 | * @return string |
||
| 527 | */ |
||
| 528 | 325 | public function getDefaultRepositoryClassName() |
|
| 534 | |||
| 535 | /** |
||
| 536 | * Set the document repository factory. |
||
| 537 | * |
||
| 538 | * @param RepositoryFactory $repositoryFactory |
||
| 539 | */ |
||
| 540 | public function setRepositoryFactory(RepositoryFactory $repositoryFactory) |
||
| 544 | |||
| 545 | /** |
||
| 546 | * Get the document repository factory. |
||
| 547 | * |
||
| 548 | * @return RepositoryFactory |
||
| 549 | */ |
||
| 550 | 933 | public function getRepositoryFactory() |
|
| 556 | |||
| 557 | /** |
||
| 558 | * Set the persistent collection factory. |
||
| 559 | * |
||
| 560 | * @param PersistentCollectionFactory $persistentCollectionFactory |
||
| 561 | */ |
||
| 562 | public function setPersistentCollectionFactory(PersistentCollectionFactory $persistentCollectionFactory) |
||
| 566 | |||
| 567 | /** |
||
| 568 | * Get the persistent collection factory. |
||
| 569 | * |
||
| 570 | * @return DefaultPersistentCollectionFactory |
||
| 571 | */ |
||
| 572 | 385 | public function getPersistentCollectionFactory() |
|
| 579 | |||
| 580 | /** |
||
| 581 | * Set the persistent collection generator. |
||
| 582 | * |
||
| 583 | * @param PersistentCollectionGenerator $persistentCollectionGenerator |
||
| 584 | */ |
||
| 585 | public function setPersistentCollectionGenerator(PersistentCollectionGenerator $persistentCollectionGenerator) |
||
| 589 | |||
| 590 | /** |
||
| 591 | * Get the persistent collection generator. |
||
| 592 | * |
||
| 593 | * @return DefaultPersistentCollectionGenerator |
||
| 594 | */ |
||
| 595 | 5 | public function getPersistentCollectionGenerator() |
|
| 605 | } |
||
| 606 |