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 |
||
43 | class Configuration extends \Doctrine\MongoDB\Configuration |
||
44 | { |
||
45 | /** |
||
46 | * Never autogenerate a proxy/hydrator and rely that it was generated by some |
||
47 | * process before deployment. Copied from \Doctrine\Common\Proxy\AbstractProxyFactory. |
||
48 | * |
||
49 | * @var integer |
||
50 | */ |
||
51 | const AUTOGENERATE_NEVER = 0; |
||
52 | |||
53 | /** |
||
54 | * Always generates a new proxy/hydrator in every request. |
||
55 | * |
||
56 | * This is only sane during development. |
||
57 | * Copied from \Doctrine\Common\Proxy\AbstractProxyFactory. |
||
58 | * |
||
59 | * @var integer |
||
60 | */ |
||
61 | const AUTOGENERATE_ALWAYS = 1; |
||
62 | |||
63 | /** |
||
64 | * Autogenerate the proxy/hydrator class when the file does not exist. |
||
65 | * |
||
66 | * This strategy causes a file exists call whenever any proxy/hydrator is used the |
||
67 | * first time in a request. Copied from \Doctrine\Common\Proxy\AbstractProxyFactory. |
||
68 | * |
||
69 | * @var integer |
||
70 | */ |
||
71 | const AUTOGENERATE_FILE_NOT_EXISTS = 2; |
||
72 | |||
73 | /** |
||
74 | * Generate the proxy/hydrator classes using eval(). |
||
75 | * |
||
76 | * This strategy is only sane for development. |
||
77 | * Copied from \Doctrine\Common\Proxy\AbstractProxyFactory. |
||
78 | * |
||
79 | * @var integer |
||
80 | */ |
||
81 | const AUTOGENERATE_EVAL = 3; |
||
82 | |||
83 | /** |
||
84 | * Adds a namespace under a certain alias. |
||
85 | * |
||
86 | * @param string $alias |
||
87 | * @param string $namespace |
||
88 | */ |
||
89 | public function addDocumentNamespace($alias, $namespace) |
||
93 | |||
94 | /** |
||
95 | * Resolves a registered namespace alias to the full namespace. |
||
96 | * |
||
97 | * @param string $documentNamespaceAlias |
||
98 | * @return string |
||
99 | * @throws MongoDBException |
||
100 | */ |
||
101 | public function getDocumentNamespace($documentNamespaceAlias) |
||
109 | |||
110 | /** |
||
111 | * Retrieves the list of registered document namespace aliases. |
||
112 | * |
||
113 | * @return array |
||
114 | */ |
||
115 | public function getDocumentNamespaces() |
||
119 | |||
120 | /** |
||
121 | * Set the document alias map |
||
122 | * |
||
123 | * @param array $documentNamespaces |
||
124 | * @return void |
||
125 | */ |
||
126 | public function setDocumentNamespaces(array $documentNamespaces) |
||
130 | |||
131 | /** |
||
132 | * Sets the cache driver implementation that is used for metadata caching. |
||
133 | * |
||
134 | * @param MappingDriver $driverImpl |
||
135 | * @todo Force parameter to be a Closure to ensure lazy evaluation |
||
136 | * (as soon as a metadata cache is in effect, the driver never needs to initialize). |
||
137 | */ |
||
138 | 937 | public function setMetadataDriverImpl(MappingDriver $driverImpl) |
|
142 | |||
143 | /** |
||
144 | * Add a new default annotation driver with a correctly configured annotation reader. |
||
145 | * |
||
146 | * @param array $paths |
||
147 | * @return Mapping\Driver\AnnotationDriver |
||
148 | */ |
||
149 | public function newDefaultAnnotationDriver($paths = array()) |
||
155 | |||
156 | /** |
||
157 | * Gets the cache driver implementation that is used for the mapping metadata. |
||
158 | * |
||
159 | * @return MappingDriver |
||
160 | */ |
||
161 | 754 | public function getMetadataDriverImpl() |
|
166 | |||
167 | /** |
||
168 | * Gets the cache driver implementation that is used for metadata caching. |
||
169 | * |
||
170 | * @return \Doctrine\Common\Cache\Cache |
||
171 | */ |
||
172 | 921 | public function getMetadataCacheImpl() |
|
177 | |||
178 | /** |
||
179 | * Sets the cache driver implementation that is used for metadata caching. |
||
180 | * |
||
181 | * @param \Doctrine\Common\Cache\Cache $cacheImpl |
||
182 | */ |
||
183 | public function setMetadataCacheImpl(Cache $cacheImpl) |
||
187 | |||
188 | /** |
||
189 | * Sets the directory where Doctrine generates any necessary proxy class files. |
||
190 | * |
||
191 | * @param string $dir |
||
192 | */ |
||
193 | 921 | public function setProxyDir($dir) |
|
197 | |||
198 | /** |
||
199 | * Gets the directory where Doctrine generates any necessary proxy class files. |
||
200 | * |
||
201 | * @return string |
||
202 | */ |
||
203 | 921 | public function getProxyDir() |
|
208 | |||
209 | /** |
||
210 | * Gets a boolean flag that indicates whether proxy classes should always be regenerated |
||
211 | * during each script execution. |
||
212 | * |
||
213 | * @return boolean|integer |
||
214 | */ |
||
215 | 921 | public function getAutoGenerateProxyClasses() |
|
220 | |||
221 | /** |
||
222 | * Sets a boolean flag that indicates whether proxy classes should always be regenerated |
||
223 | * during each script execution. |
||
224 | * |
||
225 | * @param boolean|int $bool Possible values are constants of Doctrine\Common\Proxy\AbstractProxyFactory |
||
226 | */ |
||
227 | public function setAutoGenerateProxyClasses($bool) |
||
231 | |||
232 | /** |
||
233 | * Gets the namespace where proxy classes reside. |
||
234 | * |
||
235 | * @return string |
||
236 | */ |
||
237 | 921 | public function getProxyNamespace() |
|
242 | |||
243 | /** |
||
244 | * Sets the namespace where proxy classes reside. |
||
245 | * |
||
246 | * @param string $ns |
||
247 | */ |
||
248 | 921 | public function setProxyNamespace($ns) |
|
252 | |||
253 | /** |
||
254 | * Sets the directory where Doctrine generates hydrator class files. |
||
255 | * |
||
256 | * @param string $dir |
||
257 | */ |
||
258 | 921 | public function setHydratorDir($dir) |
|
262 | |||
263 | /** |
||
264 | * Gets the directory where Doctrine generates hydrator class files. |
||
265 | * |
||
266 | * @return string |
||
267 | */ |
||
268 | 921 | public function getHydratorDir() |
|
273 | |||
274 | /** |
||
275 | * Gets a boolean flag that indicates whether hydrator classes should always be regenerated |
||
276 | * during each script execution. |
||
277 | * |
||
278 | * @return boolean|integer Possible values are defined constants |
||
279 | */ |
||
280 | 921 | public function getAutoGenerateHydratorClasses() |
|
285 | |||
286 | /** |
||
287 | * Sets a boolean flag that indicates whether hydrator classes should always be regenerated |
||
288 | * during each script execution. |
||
289 | * |
||
290 | * @param boolean|integer $bool |
||
291 | */ |
||
292 | public function setAutoGenerateHydratorClasses($bool) |
||
296 | |||
297 | /** |
||
298 | * Gets the namespace where hydrator classes reside. |
||
299 | * |
||
300 | * @return string |
||
301 | */ |
||
302 | 921 | public function getHydratorNamespace() |
|
307 | |||
308 | /** |
||
309 | * Sets the namespace where hydrator classes reside. |
||
310 | * |
||
311 | * @param string $ns |
||
312 | */ |
||
313 | 921 | public function setHydratorNamespace($ns) |
|
317 | |||
318 | |||
319 | /** |
||
320 | * Sets the default DB to use for all Documents that do not specify |
||
321 | * a database. |
||
322 | * |
||
323 | * @param string $defaultDB |
||
324 | */ |
||
325 | 921 | public function setDefaultDB($defaultDB) |
|
329 | |||
330 | /** |
||
331 | * Gets the default DB to use for all Documents that do not specify a database. |
||
332 | * |
||
333 | * @return string $defaultDB |
||
334 | */ |
||
335 | 676 | public function getDefaultDB() |
|
340 | |||
341 | /** |
||
342 | * Set the class metadata factory class name. |
||
343 | * |
||
344 | * @param string $cmfName |
||
345 | */ |
||
346 | public function setClassMetadataFactoryName($cmfName) |
||
350 | |||
351 | /** |
||
352 | * Gets the class metadata factory class name. |
||
353 | * |
||
354 | * @return string |
||
355 | */ |
||
356 | 921 | public function getClassMetadataFactoryName() |
|
363 | |||
364 | /** |
||
365 | * Gets array of default commit options. |
||
366 | * |
||
367 | * @return array |
||
368 | */ |
||
369 | 554 | public function getDefaultCommitOptions() |
|
377 | |||
378 | /** |
||
379 | * Sets array of default commit options. |
||
380 | * |
||
381 | * @param boolean $defaultCommitOptions |
||
382 | */ |
||
383 | public function setDefaultCommitOptions($defaultCommitOptions) |
||
387 | |||
388 | /** |
||
389 | * Add a filter to the list of possible filters. |
||
390 | * |
||
391 | * @param string $name The name of the filter. |
||
392 | * @param string $className The class name of the filter. |
||
393 | * @param array $parameters The parameters for the filter. |
||
394 | */ |
||
395 | 921 | public function addFilter($name, $className, array $parameters = array()) |
|
402 | |||
403 | /** |
||
404 | * Gets the class name for a given filter name. |
||
405 | * |
||
406 | * @param string $name The name of the filter. |
||
407 | * |
||
408 | * @return string|null The filter class name, or null if it is undefined |
||
409 | */ |
||
410 | 22 | public function getFilterClassName($name) |
|
416 | |||
417 | /** |
||
418 | * Gets the parameters for a given filter name. |
||
419 | * |
||
420 | * @param string $name The name of the filter. |
||
421 | * |
||
422 | * @return array|null The filter parameters, or null if it is undefined |
||
423 | */ |
||
424 | 21 | public function getFilterParameters($name) |
|
430 | |||
431 | /** |
||
432 | * Sets default repository class. |
||
433 | * |
||
434 | * @param string $className |
||
435 | * |
||
436 | * @return void |
||
437 | * |
||
438 | * @throws MongoDBException If not is a ObjectRepository |
||
439 | */ |
||
440 | public function setDefaultRepositoryClassName($className) |
||
450 | |||
451 | /** |
||
452 | * Get default repository class. |
||
453 | * |
||
454 | * @return string |
||
455 | */ |
||
456 | 320 | public function getDefaultRepositoryClassName() |
|
462 | |||
463 | /** |
||
464 | * Set the document repository factory. |
||
465 | * |
||
466 | * @param RepositoryFactory $repositoryFactory |
||
467 | */ |
||
468 | public function setRepositoryFactory(RepositoryFactory $repositoryFactory) |
||
472 | |||
473 | /** |
||
474 | * Get the document repository factory. |
||
475 | * |
||
476 | * @return RepositoryFactory |
||
477 | */ |
||
478 | 921 | public function getRepositoryFactory() |
|
484 | } |
||
485 |