Complex classes like NativeQueryWrapper 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 NativeQueryWrapper, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
27 | final class NativeQueryWrapper extends AbstractQuery |
||
28 | { |
||
29 | |||
30 | /** |
||
31 | * @var \Doctrine\ORM\NativeQuery |
||
32 | */ |
||
33 | private $nativeQuery; |
||
34 | |||
35 | /** |
||
36 | * @var int|NULL |
||
37 | */ |
||
38 | private $firstResult; |
||
39 | |||
40 | /** |
||
41 | * @var int|NULL |
||
42 | */ |
||
43 | private $maxResults; |
||
44 | |||
45 | |||
46 | |||
47 | public function __construct(NativeQuery $nativeQuery) |
||
52 | |||
53 | |||
54 | |||
55 | /** |
||
56 | * @return int|NULL |
||
57 | */ |
||
58 | public function getFirstResult() |
||
62 | |||
63 | |||
64 | |||
65 | /** |
||
66 | * @param int|NULL $firstResult |
||
67 | * @return NativeQueryWrapper |
||
68 | */ |
||
69 | public function setFirstResult($firstResult) |
||
74 | |||
75 | |||
76 | |||
77 | /** |
||
78 | * @return int|NULL |
||
79 | */ |
||
80 | public function getMaxResults() |
||
84 | |||
85 | |||
86 | |||
87 | /** |
||
88 | * @param int|NULL $maxResults |
||
89 | * @return NativeQueryWrapper |
||
90 | */ |
||
91 | public function setMaxResults($maxResults) |
||
96 | |||
97 | |||
98 | |||
99 | /** |
||
100 | * @return NativeQuery |
||
101 | */ |
||
102 | protected function getLimitedQuery() |
||
135 | |||
136 | |||
137 | |||
138 | public function iterate($parameters = null, $hydrationMode = null) |
||
142 | |||
143 | |||
144 | |||
145 | public function execute($parameters = null, $hydrationMode = null) |
||
149 | |||
150 | |||
151 | |||
152 | public function getResult($hydrationMode = self::HYDRATE_OBJECT) |
||
156 | |||
157 | |||
158 | |||
159 | public function getArrayResult() |
||
163 | |||
164 | |||
165 | |||
166 | public function getScalarResult() |
||
170 | |||
171 | |||
172 | |||
173 | public function getOneOrNullResult($hydrationMode = null) |
||
177 | |||
178 | |||
179 | |||
180 | public function getSingleResult($hydrationMode = null) |
||
184 | |||
185 | |||
186 | |||
187 | public function getSingleScalarResult() |
||
191 | |||
192 | |||
193 | |||
194 | public function setSQL($sql) |
||
199 | |||
200 | |||
201 | |||
202 | public function getSQL() |
||
206 | |||
207 | |||
208 | |||
209 | public function setCacheable($cacheable) |
||
214 | |||
215 | |||
216 | |||
217 | public function isCacheable() |
||
221 | |||
222 | |||
223 | |||
224 | public function setCacheRegion($cacheRegion) |
||
229 | |||
230 | |||
231 | |||
232 | public function getCacheRegion() |
||
236 | |||
237 | |||
238 | |||
239 | protected function isCacheEnabled() |
||
243 | |||
244 | |||
245 | |||
246 | public function getLifetime() |
||
250 | |||
251 | |||
252 | |||
253 | public function setLifetime($lifetime) |
||
258 | |||
259 | |||
260 | |||
261 | public function getCacheMode() |
||
265 | |||
266 | |||
267 | |||
268 | public function setCacheMode($cacheMode) |
||
273 | |||
274 | |||
275 | |||
276 | public function getEntityManager() |
||
280 | |||
281 | |||
282 | |||
283 | public function free() |
||
287 | |||
288 | |||
289 | |||
290 | public function getParameters() |
||
294 | |||
295 | |||
296 | |||
297 | public function getParameter($key) |
||
301 | |||
302 | |||
303 | |||
304 | public function setParameters($parameters) |
||
309 | |||
310 | |||
311 | |||
312 | public function setParameter($key, $value, $type = null) |
||
317 | |||
318 | |||
319 | |||
320 | public function processParameterValue($value) |
||
324 | |||
325 | |||
326 | |||
327 | public function setResultSetMapping(Query\ResultSetMapping $rsm) |
||
332 | |||
333 | |||
334 | |||
335 | protected function getResultSetMapping() |
||
339 | |||
340 | |||
341 | |||
342 | public function setHydrationCacheProfile(QueryCacheProfile $profile = null) |
||
347 | |||
348 | |||
349 | |||
350 | public function getHydrationCacheProfile() |
||
354 | |||
355 | |||
356 | |||
357 | public function setResultCacheProfile(QueryCacheProfile $profile = null) |
||
362 | |||
363 | |||
364 | |||
365 | public function setResultCacheDriver($resultCacheDriver = null) |
||
370 | |||
371 | |||
372 | |||
373 | public function getResultCacheDriver() |
||
377 | |||
378 | |||
379 | |||
380 | public function useResultCache($bool, $lifetime = null, $resultCacheId = null) |
||
385 | |||
386 | |||
387 | |||
388 | public function setResultCacheLifetime($lifetime) |
||
393 | |||
394 | |||
395 | |||
396 | public function getResultCacheLifetime() |
||
400 | |||
401 | |||
402 | |||
403 | public function expireResultCache($expire = true) |
||
408 | |||
409 | |||
410 | |||
411 | public function getExpireResultCache() |
||
415 | |||
416 | |||
417 | |||
418 | public function getQueryCacheProfile() |
||
422 | |||
423 | |||
424 | |||
425 | public function setFetchMode($class, $assocName, $fetchMode) |
||
430 | |||
431 | |||
432 | |||
433 | public function setHydrationMode($hydrationMode) |
||
438 | |||
439 | |||
440 | |||
441 | public function getHydrationMode() |
||
445 | |||
446 | |||
447 | |||
448 | public function setHint($name, $value) |
||
453 | |||
454 | |||
455 | |||
456 | public function getHint($name) |
||
460 | |||
461 | |||
462 | |||
463 | public function hasHint($name) |
||
467 | |||
468 | |||
469 | |||
470 | public function getHints() |
||
474 | |||
475 | |||
476 | |||
477 | protected function getHydrationCacheId() |
||
481 | |||
482 | |||
483 | |||
484 | public function setResultCacheId($id) |
||
489 | |||
490 | |||
491 | |||
492 | public function getResultCacheId() |
||
496 | |||
497 | |||
498 | |||
499 | protected function getHash() |
||
503 | |||
504 | |||
505 | |||
506 | protected function _doExecute() |
||
510 | |||
511 | |||
512 | |||
513 | public function __clone() |
||
517 | |||
518 | } |
||
519 |
This check looks for access to methods that are not accessible from the current context.
If you need to make a method accessible to another context you can raise its visibility level in the defining class.