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 |
||
| 47 | class Configuration extends \Doctrine\MongoDB\Configuration |
||
| 48 | { |
||
| 49 | /** |
||
| 50 | * Never autogenerate a proxy/hydrator/persistent collection and rely that |
||
| 51 | * it was generated by some process before deployment. Copied from |
||
| 52 | * \Doctrine\Common\Proxy\AbstractProxyFactory. |
||
| 53 | * |
||
| 54 | * @var integer |
||
| 55 | */ |
||
| 56 | const AUTOGENERATE_NEVER = 0; |
||
| 57 | |||
| 58 | /** |
||
| 59 | * Always generates a new proxy/hydrator/persistent collection in every request. |
||
| 60 | * |
||
| 61 | * This is only sane during development. |
||
| 62 | * Copied from \Doctrine\Common\Proxy\AbstractProxyFactory. |
||
| 63 | * |
||
| 64 | * @var integer |
||
| 65 | */ |
||
| 66 | const AUTOGENERATE_ALWAYS = 1; |
||
| 67 | |||
| 68 | /** |
||
| 69 | * Autogenerate the proxy/hydrator/persistent collection class when the file does not exist. |
||
| 70 | * |
||
| 71 | * This strategy causes a file exists call whenever any proxy/hydrator is used the |
||
| 72 | * first time in a request. Copied from \Doctrine\Common\Proxy\AbstractProxyFactory. |
||
| 73 | * |
||
| 74 | * @var integer |
||
| 75 | */ |
||
| 76 | const AUTOGENERATE_FILE_NOT_EXISTS = 2; |
||
| 77 | |||
| 78 | /** |
||
| 79 | * Generate the proxy/hydrator/persistent collection classes using eval(). |
||
| 80 | * |
||
| 81 | * This strategy is only sane for development. |
||
| 82 | * Copied from \Doctrine\Common\Proxy\AbstractProxyFactory. |
||
| 83 | * |
||
| 84 | * @var integer |
||
| 85 | */ |
||
| 86 | const AUTOGENERATE_EVAL = 3; |
||
| 87 | |||
| 88 | /** |
||
| 89 | * Adds a namespace under a certain alias. |
||
| 90 | * |
||
| 91 | * @param string $alias |
||
| 92 | * @param string $namespace |
||
| 93 | */ |
||
| 94 | public function addDocumentNamespace($alias, $namespace) |
||
| 98 | |||
| 99 | /** |
||
| 100 | * Resolves a registered namespace alias to the full namespace. |
||
| 101 | * |
||
| 102 | * @param string $documentNamespaceAlias |
||
| 103 | * @return string |
||
| 104 | * @throws MongoDBException |
||
| 105 | */ |
||
| 106 | public function getDocumentNamespace($documentNamespaceAlias) |
||
| 114 | |||
| 115 | /** |
||
| 116 | * Retrieves the list of registered document namespace aliases. |
||
| 117 | * |
||
| 118 | * @return array |
||
| 119 | */ |
||
| 120 | public function getDocumentNamespaces() |
||
| 124 | |||
| 125 | /** |
||
| 126 | * Set the document alias map |
||
| 127 | * |
||
| 128 | * @param array $documentNamespaces |
||
| 129 | * @return void |
||
| 130 | */ |
||
| 131 | public function setDocumentNamespaces(array $documentNamespaces) |
||
| 135 | |||
| 136 | /** |
||
| 137 | * Sets the cache driver implementation that is used for metadata caching. |
||
| 138 | 993 | * |
|
| 139 | * @param MappingDriver $driverImpl |
||
| 140 | 993 | * @todo Force parameter to be a Closure to ensure lazy evaluation |
|
| 141 | 993 | * (as soon as a metadata cache is in effect, the driver never needs to initialize). |
|
| 142 | */ |
||
| 143 | public function setMetadataDriverImpl(MappingDriver $driverImpl) |
||
| 147 | |||
| 148 | /** |
||
| 149 | * Add a new default annotation driver with a correctly configured annotation reader. |
||
| 150 | * |
||
| 151 | * @param array $paths |
||
| 152 | * @return Mapping\Driver\AnnotationDriver |
||
| 153 | */ |
||
| 154 | public function newDefaultAnnotationDriver($paths = array()) |
||
| 160 | |||
| 161 | 807 | /** |
|
| 162 | * Gets the cache driver implementation that is used for the mapping metadata. |
||
| 163 | 807 | * |
|
| 164 | 807 | * @return MappingDriver |
|
| 165 | */ |
||
| 166 | public function getMetadataDriverImpl() |
||
| 171 | |||
| 172 | 948 | /** |
|
| 173 | * Gets the cache driver implementation that is used for metadata caching. |
||
| 174 | 948 | * |
|
| 175 | 948 | * @return \Doctrine\Common\Cache\Cache |
|
| 176 | */ |
||
| 177 | public function getMetadataCacheImpl() |
||
| 182 | |||
| 183 | /** |
||
| 184 | * Sets the cache driver implementation that is used for metadata caching. |
||
| 185 | * |
||
| 186 | * @param \Doctrine\Common\Cache\Cache $cacheImpl |
||
| 187 | */ |
||
| 188 | public function setMetadataCacheImpl(Cache $cacheImpl) |
||
| 192 | |||
| 193 | 948 | /** |
|
| 194 | * Sets the directory where Doctrine generates any necessary proxy class files. |
||
| 195 | 948 | * |
|
| 196 | 948 | * @param string $dir |
|
| 197 | */ |
||
| 198 | public function setProxyDir($dir) |
||
| 202 | |||
| 203 | 948 | /** |
|
| 204 | * Gets the directory where Doctrine generates any necessary proxy class files. |
||
| 205 | 948 | * |
|
| 206 | 948 | * @return string |
|
| 207 | */ |
||
| 208 | public function getProxyDir() |
||
| 213 | |||
| 214 | /** |
||
| 215 | 948 | * Gets a boolean flag that indicates whether proxy classes should always be regenerated |
|
| 216 | * during each script execution. |
||
| 217 | 948 | * |
|
| 218 | 948 | * @return boolean|integer |
|
| 219 | */ |
||
| 220 | public function getAutoGenerateProxyClasses() |
||
| 225 | |||
| 226 | /** |
||
| 227 | * Sets a boolean flag that indicates whether proxy classes should always be regenerated |
||
| 228 | * during each script execution. |
||
| 229 | * |
||
| 230 | * @param boolean|int $bool Possible values are constants of Doctrine\Common\Proxy\AbstractProxyFactory |
||
| 231 | */ |
||
| 232 | public function setAutoGenerateProxyClasses($bool) |
||
| 236 | |||
| 237 | 948 | /** |
|
| 238 | * Gets the namespace where proxy classes reside. |
||
| 239 | 948 | * |
|
| 240 | 948 | * @return string |
|
| 241 | */ |
||
| 242 | public function getProxyNamespace() |
||
| 247 | |||
| 248 | 948 | /** |
|
| 249 | * Sets the namespace where proxy classes reside. |
||
| 250 | 948 | * |
|
| 251 | 948 | * @param string $ns |
|
| 252 | */ |
||
| 253 | public function setProxyNamespace($ns) |
||
| 257 | |||
| 258 | 948 | /** |
|
| 259 | * Sets the directory where Doctrine generates hydrator class files. |
||
| 260 | 948 | * |
|
| 261 | 948 | * @param string $dir |
|
| 262 | */ |
||
| 263 | public function setHydratorDir($dir) |
||
| 267 | |||
| 268 | 948 | /** |
|
| 269 | * Gets the directory where Doctrine generates hydrator class files. |
||
| 270 | 948 | * |
|
| 271 | 948 | * @return string |
|
| 272 | */ |
||
| 273 | public function getHydratorDir() |
||
| 278 | |||
| 279 | /** |
||
| 280 | 948 | * Gets a boolean flag that indicates whether hydrator classes should always be regenerated |
|
| 281 | * during each script execution. |
||
| 282 | 948 | * |
|
| 283 | 948 | * @return boolean|integer Possible values are defined constants |
|
| 284 | */ |
||
| 285 | public function getAutoGenerateHydratorClasses() |
||
| 290 | |||
| 291 | /** |
||
| 292 | * Sets a boolean flag that indicates whether hydrator classes should always be regenerated |
||
| 293 | * during each script execution. |
||
| 294 | * |
||
| 295 | * @param boolean|integer $bool |
||
| 296 | */ |
||
| 297 | public function setAutoGenerateHydratorClasses($bool) |
||
| 301 | |||
| 302 | 948 | /** |
|
| 303 | * Gets the namespace where hydrator classes reside. |
||
| 304 | 948 | * |
|
| 305 | 948 | * @return string |
|
| 306 | */ |
||
| 307 | public function getHydratorNamespace() |
||
| 312 | |||
| 313 | 948 | /** |
|
| 314 | * Sets the namespace where hydrator classes reside. |
||
| 315 | 948 | * |
|
| 316 | 948 | * @param string $ns |
|
| 317 | */ |
||
| 318 | public function setHydratorNamespace($ns) |
||
| 322 | |||
| 323 | /** |
||
| 324 | * Sets the directory where Doctrine generates persistent collection class files. |
||
| 325 | 948 | * |
|
| 326 | * @param string $dir |
||
| 327 | 948 | */ |
|
| 328 | 948 | public function setPersistentCollectionDir($dir) |
|
| 332 | |||
| 333 | /** |
||
| 334 | * Gets the directory where Doctrine generates persistent collection class files. |
||
| 335 | 700 | * |
|
| 336 | * @return string |
||
| 337 | 700 | */ |
|
| 338 | 700 | public function getPersistentCollectionDir() |
|
| 343 | |||
| 344 | /** |
||
| 345 | * Gets a integer flag that indicates how and when persistent collection |
||
| 346 | * classes should be generated. |
||
| 347 | * |
||
| 348 | * @return integer Possible values are defined constants |
||
| 349 | */ |
||
| 350 | public function getAutoGeneratePersistentCollectionClasses() |
||
| 355 | |||
| 356 | 948 | /** |
|
| 357 | * Sets a integer flag that indicates how and when persistent collection |
||
| 358 | 948 | * classes should be generated. |
|
| 359 | 948 | * |
|
| 360 | 948 | * @param integer $mode Possible values are defined constants |
|
| 361 | 948 | */ |
|
| 362 | public function setAutoGeneratePersistentCollectionClasses($mode) |
||
| 366 | |||
| 367 | /** |
||
| 368 | * Gets the namespace where persistent collection classes reside. |
||
| 369 | 569 | * |
|
| 370 | * @return string |
||
| 371 | 569 | */ |
|
| 372 | public function getPersistentCollectionNamespace() |
||
| 377 | |||
| 378 | /** |
||
| 379 | * Sets the namespace where persistent collection classes reside. |
||
| 380 | * |
||
| 381 | * @param string $ns |
||
| 382 | */ |
||
| 383 | public function setPersistentCollectionNamespace($ns) |
||
| 387 | |||
| 388 | /** |
||
| 389 | * Sets the default DB to use for all Documents that do not specify |
||
| 390 | * a database. |
||
| 391 | * |
||
| 392 | * @param string $defaultDB |
||
| 393 | */ |
||
| 394 | public function setDefaultDB($defaultDB) |
||
| 398 | 948 | ||
| 399 | /** |
||
| 400 | 948 | * Gets the default DB to use for all Documents that do not specify a database. |
|
| 401 | 948 | * |
|
| 402 | * @return string $defaultDB |
||
| 403 | */ |
||
| 404 | public function getDefaultDB() |
||
| 409 | |||
| 410 | 22 | /** |
|
| 411 | * Set the class metadata factory class name. |
||
| 412 | 22 | * |
|
| 413 | 22 | * @param string $cmfName |
|
| 414 | 22 | */ |
|
| 415 | public function setClassMetadataFactoryName($cmfName) |
||
| 419 | |||
| 420 | /** |
||
| 421 | * Gets the class metadata factory class name. |
||
| 422 | * |
||
| 423 | * @return string |
||
| 424 | 21 | */ |
|
| 425 | public function getClassMetadataFactoryName() |
||
| 432 | |||
| 433 | /** |
||
| 434 | * Gets array of default commit options. |
||
| 435 | * |
||
| 436 | * @return array |
||
| 437 | */ |
||
| 438 | public function getDefaultCommitOptions() |
||
| 446 | |||
| 447 | /** |
||
| 448 | * Sets array of default commit options. |
||
| 449 | * |
||
| 450 | * @param boolean $defaultCommitOptions |
||
| 451 | */ |
||
| 452 | public function setDefaultCommitOptions($defaultCommitOptions) |
||
| 456 | 333 | ||
| 457 | /** |
||
| 458 | 333 | * Add a filter to the list of possible filters. |
|
| 459 | 333 | * |
|
| 460 | 333 | * @param string $name The name of the filter. |
|
| 461 | * @param string $className The class name of the filter. |
||
| 462 | * @param array $parameters The parameters for the filter. |
||
| 463 | */ |
||
| 464 | public function addFilter($name, $className, array $parameters = array()) |
||
| 471 | |||
| 472 | /** |
||
| 473 | * Gets the class name for a given filter name. |
||
| 474 | * |
||
| 475 | * @param string $name The name of the filter. |
||
| 476 | * |
||
| 477 | * @return string|null The filter class name, or null if it is undefined |
||
| 478 | 948 | */ |
|
| 479 | public function getFilterClassName($name) |
||
| 485 | |||
| 486 | /** |
||
| 487 | * Gets the parameters for a given filter name. |
||
| 488 | * |
||
| 489 | * @param string $name The name of the filter. |
||
| 490 | * |
||
| 491 | * @return array|null The filter parameters, or null if it is undefined |
||
| 492 | */ |
||
| 493 | public function getFilterParameters($name) |
||
| 499 | |||
| 500 | /** |
||
| 501 | * Sets default repository class. |
||
| 502 | * |
||
| 503 | * @param string $className |
||
| 504 | * |
||
| 505 | * @return void |
||
| 506 | * |
||
| 507 | * @throws MongoDBException If not is a ObjectRepository |
||
| 508 | */ |
||
| 509 | public function setDefaultRepositoryClassName($className) |
||
| 519 | |||
| 520 | /** |
||
| 521 | * Get default repository class. |
||
| 522 | * |
||
| 523 | * @return string |
||
| 524 | */ |
||
| 525 | public function getDefaultRepositoryClassName() |
||
| 531 | |||
| 532 | /** |
||
| 533 | * Set the document repository factory. |
||
| 534 | * |
||
| 535 | * @param RepositoryFactory $repositoryFactory |
||
| 536 | */ |
||
| 537 | public function setRepositoryFactory(RepositoryFactory $repositoryFactory) |
||
| 541 | |||
| 542 | /** |
||
| 543 | * Get the document repository factory. |
||
| 544 | * |
||
| 545 | * @return RepositoryFactory |
||
| 546 | */ |
||
| 547 | public function getRepositoryFactory() |
||
| 553 | |||
| 554 | /** |
||
| 555 | * Set the persistent collection factory. |
||
| 556 | * |
||
| 557 | * @param PersistentCollectionFactory $persistentCollectionFactory |
||
| 558 | */ |
||
| 559 | public function setPersistentCollectionFactory(PersistentCollectionFactory $persistentCollectionFactory) |
||
| 563 | |||
| 564 | /** |
||
| 565 | * Get the persistent collection factory. |
||
| 566 | * |
||
| 567 | * @return DefaultPersistentCollectionFactory |
||
| 568 | */ |
||
| 569 | public function getPersistentCollectionFactory() |
||
| 576 | |||
| 577 | /** |
||
| 578 | * Set the persistent collection generator. |
||
| 579 | * |
||
| 580 | * @param PersistentCollectionGenerator $persistentCollectionGenerator |
||
| 581 | */ |
||
| 582 | public function setPersistentCollectionGenerator(PersistentCollectionGenerator $persistentCollectionGenerator) |
||
| 586 | |||
| 587 | /** |
||
| 588 | * Get the persistent collection generator. |
||
| 589 | * |
||
| 590 | * @return DefaultPersistentCollectionGenerator |
||
| 591 | */ |
||
| 592 | public function getPersistentCollectionGenerator() |
||
| 602 | } |
||
| 603 |