Complex classes like RelationalBuilder 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 RelationalBuilder, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
42 | class RelationalBuilder extends AbstractManagerBuilder |
||
43 | { |
||
44 | /** |
||
45 | * Query cache driver. |
||
46 | * |
||
47 | * @var CacheProvider |
||
48 | */ |
||
49 | protected $queryCacheDriver; |
||
50 | |||
51 | /** |
||
52 | * Result cache driver. |
||
53 | * |
||
54 | * @var CacheProvider |
||
55 | */ |
||
56 | protected $resultCacheDriver; |
||
57 | |||
58 | /** |
||
59 | * Hydrator cache driver. |
||
60 | * |
||
61 | * @var CacheProvider |
||
62 | */ |
||
63 | protected $hydratorCacheDriver; |
||
64 | |||
65 | /** |
||
66 | * Naming strategy. |
||
67 | * |
||
68 | * @var NamingStrategy |
||
69 | */ |
||
70 | protected $namingStrategy; |
||
71 | |||
72 | /** |
||
73 | * Quote strategy. |
||
74 | * |
||
75 | * @var QuoteStrategy |
||
76 | */ |
||
77 | protected $quoteStrategy; |
||
78 | |||
79 | /** |
||
80 | * Second level cache configuration. |
||
81 | * |
||
82 | * @var CacheConfiguration |
||
83 | */ |
||
84 | protected $secondCacheConfig; |
||
85 | |||
86 | /** |
||
87 | * SQL logger. |
||
88 | * |
||
89 | * @var SQLLogger |
||
90 | */ |
||
91 | protected $SQLLogger; |
||
92 | |||
93 | /** |
||
94 | * {@inheritdoc} |
||
95 | */ |
||
96 | protected function getDefaultOptions() |
||
109 | |||
110 | /** |
||
111 | * {@inheritdoc} |
||
112 | */ |
||
113 | protected function wipe() |
||
125 | |||
126 | /** |
||
127 | * {@inheritdoc} |
||
128 | * |
||
129 | * @throws \Doctrine\DBAL\DBALException |
||
130 | * @throws \Doctrine\ORM\ORMException |
||
131 | * @throws \InvalidArgumentException |
||
132 | * @throws \RuntimeException |
||
133 | * @throws \UnexpectedValueException |
||
134 | * |
||
135 | * @return EntityManager |
||
136 | */ |
||
137 | protected function buildManager() |
||
174 | |||
175 | /** |
||
176 | * Set up general manager configurations. |
||
177 | * |
||
178 | * @param Configuration $config |
||
179 | */ |
||
180 | protected function setUpGeneralConfigurations(Configuration $config) |
||
199 | |||
200 | /** |
||
201 | * Set up manager specific configurations. |
||
202 | * |
||
203 | * @param Configuration $config |
||
204 | */ |
||
205 | protected function setUpSpecificConfigurations(Configuration $config) |
||
228 | |||
229 | /** |
||
230 | * {@inheritdoc} |
||
231 | */ |
||
232 | protected function getAnnotationMappingDriver(array $paths) |
||
236 | |||
237 | /** |
||
238 | * {@inheritdoc} |
||
239 | */ |
||
240 | protected function getXmlMappingDriver(array $paths, $extension = null) |
||
246 | |||
247 | /** |
||
248 | * {@inheritdoc} |
||
249 | */ |
||
250 | protected function getYamlMappingDriver(array $paths, $extension = null) |
||
256 | |||
257 | /** |
||
258 | * {@inheritdoc} |
||
259 | * |
||
260 | * @throws \InvalidArgumentException |
||
261 | * |
||
262 | * @return RepositoryFactory|null |
||
263 | */ |
||
264 | protected function getRepositoryFactory() |
||
281 | |||
282 | /** |
||
283 | * Retrieve query cache driver. |
||
284 | * |
||
285 | * @throws \InvalidArgumentException |
||
286 | * |
||
287 | * @return CacheProvider |
||
288 | */ |
||
289 | public function getQueryCacheDriver() |
||
300 | |||
301 | /** |
||
302 | * Set query cache driver. |
||
303 | * |
||
304 | * @param CacheProvider $queryCacheDriver |
||
305 | */ |
||
306 | public function setQueryCacheDriver(CacheProvider $queryCacheDriver) |
||
310 | |||
311 | /** |
||
312 | * Retrieve result cache driver. |
||
313 | * |
||
314 | * @throws \InvalidArgumentException |
||
315 | * |
||
316 | * @return CacheProvider |
||
317 | */ |
||
318 | public function getResultCacheDriver() |
||
329 | |||
330 | /** |
||
331 | * Set result cache driver. |
||
332 | * |
||
333 | * @param CacheProvider $resultCacheDriver |
||
334 | */ |
||
335 | public function setResultCacheDriver(CacheProvider $resultCacheDriver) |
||
339 | |||
340 | /** |
||
341 | * Retrieve hydrator cache driver. |
||
342 | * |
||
343 | * @throws \InvalidArgumentException |
||
344 | * |
||
345 | * @return CacheProvider |
||
346 | */ |
||
347 | public function getHydratorCacheDriver() |
||
358 | |||
359 | /** |
||
360 | * Set hydrator cache driver. |
||
361 | * |
||
362 | * @param CacheProvider $hydratorCacheDriver |
||
363 | */ |
||
364 | public function setHydratorCacheDriver(CacheProvider $hydratorCacheDriver) |
||
368 | |||
369 | /** |
||
370 | * Get cache driver. |
||
371 | * |
||
372 | * @param string $cacheNamespace |
||
373 | * @param CacheProvider|null $cacheDriver |
||
374 | * |
||
375 | * @return CacheProvider |
||
376 | */ |
||
377 | protected function getCacheDriver($cacheNamespace, CacheProvider $cacheDriver = null) |
||
390 | |||
391 | /** |
||
392 | * Retrieve naming strategy. |
||
393 | * |
||
394 | * @return NamingStrategy |
||
395 | */ |
||
396 | protected function getNamingStrategy() |
||
410 | |||
411 | /** |
||
412 | * Retrieve quote strategy. |
||
413 | * |
||
414 | * @throws \InvalidArgumentException |
||
415 | * |
||
416 | * @return QuoteStrategy |
||
417 | */ |
||
418 | protected function getQuoteStrategy() |
||
432 | |||
433 | /** |
||
434 | * Retrieve second level cache configuration. |
||
435 | * |
||
436 | * @return CacheConfiguration|null |
||
437 | */ |
||
438 | protected function getSecondLevelCacheConfiguration() |
||
450 | |||
451 | /** |
||
452 | * Retrieve SQL logger. |
||
453 | * |
||
454 | * @return SQLLogger|null |
||
455 | */ |
||
456 | protected function getSQLLogger() |
||
468 | |||
469 | /** |
||
470 | * Retrieve custom DQL string functions. |
||
471 | * |
||
472 | * @return array |
||
473 | */ |
||
474 | protected function getCustomStringFunctions() |
||
486 | |||
487 | /** |
||
488 | * Retrieve custom DQL numeric functions. |
||
489 | * |
||
490 | * @return array |
||
491 | */ |
||
492 | protected function getCustomNumericFunctions() |
||
504 | |||
505 | /** |
||
506 | * Retrieve custom DQL date time functions. |
||
507 | * |
||
508 | * @return array |
||
509 | */ |
||
510 | protected function getCustomDateTimeFunctions() |
||
522 | |||
523 | /** |
||
524 | * Retrieve custom DBAL types. |
||
525 | * |
||
526 | * @return array |
||
527 | */ |
||
528 | protected function getCustomTypes() |
||
540 | |||
541 | /** |
||
542 | * Retrieve custom DBAL mapping types. |
||
543 | * |
||
544 | * @return array |
||
545 | */ |
||
546 | protected function getCustomMappingTypes() |
||
558 | |||
559 | /** |
||
560 | * Get custom registered filters. |
||
561 | * |
||
562 | * @return array |
||
563 | */ |
||
564 | protected function getCustomFilters() |
||
576 | |||
577 | /** |
||
578 | * {@inheritdoc} |
||
579 | * |
||
580 | * @throws \Doctrine\DBAL\DBALException |
||
581 | * @throws \Doctrine\ORM\ORMException |
||
582 | * @throws \InvalidArgumentException |
||
583 | * @throws \RuntimeException |
||
584 | * @throws \Symfony\Component\Console\Exception\InvalidArgumentException |
||
585 | * @throws \Symfony\Component\Console\Exception\LogicException |
||
586 | * @throws \UnexpectedValueException |
||
587 | * |
||
588 | * @return Command[] |
||
589 | */ |
||
590 | public function getConsoleCommands() |
||
645 | |||
646 | /** |
||
647 | * Get console helper set. |
||
648 | * |
||
649 | * @return \Symfony\Component\Console\Helper\HelperSet |
||
650 | */ |
||
651 | protected function getConsoleHelperSet() |
||
661 | } |
||
662 |
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.