Complex classes like SessionFunctions 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 SessionFunctions, and based on these observations, apply Extract Interface, too.
1 | <?php namespace Limoncello\Application\Session; |
||
26 | class SessionFunctions implements SessionFunctionsInterface |
||
27 | { |
||
28 | /** |
||
29 | * @var callable |
||
30 | */ |
||
31 | private $retrieveCallable; |
||
32 | |||
33 | /** |
||
34 | * @var callable |
||
35 | */ |
||
36 | private $putCallable; |
||
37 | |||
38 | /** |
||
39 | * @var callable |
||
40 | */ |
||
41 | private $hasCallable; |
||
42 | |||
43 | /** |
||
44 | * @var callable |
||
45 | */ |
||
46 | private $deleteCallable; |
||
47 | |||
48 | /** |
||
49 | * @var callable |
||
50 | */ |
||
51 | private $iteratorCallable; |
||
52 | |||
53 | /** |
||
54 | * @var callable |
||
55 | */ |
||
56 | private $abortCallable; |
||
57 | |||
58 | /** |
||
59 | * @var callable |
||
60 | */ |
||
61 | private $cacheLimiterCallable; |
||
62 | |||
63 | /** |
||
64 | * @var callable |
||
65 | */ |
||
66 | private $createIdCallable; |
||
67 | |||
68 | /** |
||
69 | * @var callable |
||
70 | */ |
||
71 | private $writeCloseCallable; |
||
72 | |||
73 | /** |
||
74 | * @var callable |
||
75 | */ |
||
76 | private $unsetCallable; |
||
77 | |||
78 | /** |
||
79 | * @var callable |
||
80 | */ |
||
81 | private $statusCallable; |
||
82 | |||
83 | /** |
||
84 | * @var callable |
||
85 | */ |
||
86 | private $startCallable; |
||
87 | |||
88 | /** |
||
89 | * @var callable |
||
90 | */ |
||
91 | private $setSaveHandlerCallable; |
||
92 | |||
93 | /** |
||
94 | * @var callable |
||
95 | */ |
||
96 | private $setCookieParamsCallable; |
||
97 | |||
98 | /** |
||
99 | * @var callable |
||
100 | */ |
||
101 | private $savePathCallable; |
||
102 | |||
103 | /** |
||
104 | * @var callable |
||
105 | */ |
||
106 | private $resetCallable; |
||
107 | |||
108 | /** |
||
109 | * @var callable |
||
110 | */ |
||
111 | private $registerShutdownCallable; |
||
112 | |||
113 | /** |
||
114 | * @var callable |
||
115 | */ |
||
116 | private $regenerateIdCallable; |
||
117 | |||
118 | /** |
||
119 | * @var callable |
||
120 | */ |
||
121 | private $nameCallable; |
||
122 | |||
123 | /** |
||
124 | * @var callable |
||
125 | */ |
||
126 | private $moduleNameCallable; |
||
127 | |||
128 | /** |
||
129 | * @var callable |
||
130 | */ |
||
131 | private $decodeCallable; |
||
132 | |||
133 | /** |
||
134 | * @var callable |
||
135 | */ |
||
136 | private $destroyCallable; |
||
137 | |||
138 | /** |
||
139 | * @var callable |
||
140 | */ |
||
141 | private $encodeCallable; |
||
142 | |||
143 | /** |
||
144 | * @var callable |
||
145 | */ |
||
146 | private $gcCallable; |
||
147 | |||
148 | /** |
||
149 | * @var callable |
||
150 | */ |
||
151 | private $getCookieParamsCallable; |
||
152 | |||
153 | /** |
||
154 | * @var callable |
||
155 | */ |
||
156 | private $idCallable; |
||
157 | /** |
||
158 | * @var callable |
||
159 | */ |
||
160 | private $cacheExpireCallable; |
||
161 | |||
162 | /** |
||
163 | * Constructor. |
||
164 | */ |
||
165 | public function __construct() |
||
206 | |||
207 | /** |
||
208 | * @inheritdoc |
||
209 | */ |
||
210 | public function getRetrieveCallable(): callable |
||
214 | |||
215 | /** |
||
216 | * @inheritdoc |
||
217 | */ |
||
218 | public function setRetrieveCallable(callable $callable): SessionFunctionsInterface |
||
224 | |||
225 | /** |
||
226 | * @inheritdoc |
||
227 | */ |
||
228 | public function getPutCallable(): callable |
||
232 | |||
233 | /** |
||
234 | * @inheritdoc |
||
235 | */ |
||
236 | public function setPutCallable(callable $callable): SessionFunctionsInterface |
||
242 | |||
243 | /** |
||
244 | * @inheritdoc |
||
245 | */ |
||
246 | public function getHasCallable(): callable |
||
250 | |||
251 | /** |
||
252 | * @inheritdoc |
||
253 | */ |
||
254 | public function setHasCallable(callable $callable): SessionFunctionsInterface |
||
260 | |||
261 | /** |
||
262 | * @inheritdoc |
||
263 | */ |
||
264 | public function getDeleteCallable(): callable |
||
268 | |||
269 | /** |
||
270 | * @inheritdoc |
||
271 | */ |
||
272 | public function setDeleteCallable(callable $callable): SessionFunctionsInterface |
||
278 | |||
279 | /** |
||
280 | * @inheritdoc |
||
281 | */ |
||
282 | public function getIteratorCallable(): callable |
||
286 | |||
287 | /** |
||
288 | * @inheritdoc |
||
289 | */ |
||
290 | public function setIteratorCallable(callable $callable): SessionFunctionsInterface |
||
296 | |||
297 | /** |
||
298 | * @inheritdoc |
||
299 | */ |
||
300 | public function getAbortCallable(): callable |
||
304 | |||
305 | /** |
||
306 | * @inheritdoc |
||
307 | */ |
||
308 | public function setAbortCallable(callable $callable): SessionFunctionsInterface |
||
314 | |||
315 | /** |
||
316 | * @inheritdoc |
||
317 | */ |
||
318 | public function getCacheExpireCallable(): callable |
||
322 | |||
323 | /** |
||
324 | * @inheritdoc |
||
325 | */ |
||
326 | public function setCacheExpireCallable(callable $callable): SessionFunctionsInterface |
||
332 | |||
333 | /** |
||
334 | * @inheritdoc |
||
335 | */ |
||
336 | public function getCacheLimiterCallable(): callable |
||
340 | |||
341 | /** |
||
342 | * @inheritdoc |
||
343 | */ |
||
344 | public function setCacheLimiterCallable(callable $callable): SessionFunctionsInterface |
||
350 | |||
351 | /** |
||
352 | * @inheritdoc |
||
353 | */ |
||
354 | public function getCreateIdCallable(): callable |
||
358 | |||
359 | /** |
||
360 | * @inheritdoc |
||
361 | */ |
||
362 | public function setCreateIdCallable(callable $callable): SessionFunctionsInterface |
||
368 | |||
369 | /** |
||
370 | * @inheritdoc |
||
371 | */ |
||
372 | public function getDecodeCallable(): callable |
||
376 | |||
377 | /** |
||
378 | * @inheritdoc |
||
379 | */ |
||
380 | public function setDecodeCallable(callable $callable): SessionFunctionsInterface |
||
386 | |||
387 | /** |
||
388 | * @inheritdoc |
||
389 | */ |
||
390 | public function getDestroyCallable(): callable |
||
394 | |||
395 | /** |
||
396 | * @inheritdoc |
||
397 | */ |
||
398 | public function setDestroyCallable(callable $callable): SessionFunctionsInterface |
||
404 | |||
405 | /** |
||
406 | * @inheritdoc |
||
407 | */ |
||
408 | public function getEncodeCallable(): callable |
||
412 | |||
413 | /** |
||
414 | * @inheritdoc |
||
415 | */ |
||
416 | public function setEncodeCallable(callable $callable): SessionFunctionsInterface |
||
422 | |||
423 | /** |
||
424 | * @inheritdoc |
||
425 | */ |
||
426 | public function getGcCallable(): callable |
||
430 | |||
431 | /** |
||
432 | * @inheritdoc |
||
433 | */ |
||
434 | public function setGcCallable(callable $callable): SessionFunctionsInterface |
||
440 | |||
441 | /** |
||
442 | * @inheritdoc |
||
443 | */ |
||
444 | public function getGetCookieParamsCallable(): callable |
||
448 | |||
449 | /** |
||
450 | * @inheritdoc |
||
451 | */ |
||
452 | public function setGetCookieParamsCallable(callable $callable): SessionFunctionsInterface |
||
458 | |||
459 | /** |
||
460 | * @inheritdoc |
||
461 | */ |
||
462 | public function getIdCallable(): callable |
||
466 | |||
467 | /** |
||
468 | * @inheritdoc |
||
469 | */ |
||
470 | public function setIdCallable(callable $callable): SessionFunctionsInterface |
||
476 | |||
477 | /** |
||
478 | * @inheritdoc |
||
479 | */ |
||
480 | public function getModuleNameCallable(): callable |
||
484 | |||
485 | /** |
||
486 | * @inheritdoc |
||
487 | */ |
||
488 | public function setModuleNameCallable(callable $callable): SessionFunctionsInterface |
||
494 | |||
495 | /** |
||
496 | * @inheritdoc |
||
497 | */ |
||
498 | public function getNameCallable(): callable |
||
502 | |||
503 | /** |
||
504 | * @inheritdoc |
||
505 | */ |
||
506 | public function setNameCallable(callable $callable): SessionFunctionsInterface |
||
512 | |||
513 | /** |
||
514 | * @inheritdoc |
||
515 | */ |
||
516 | public function getRegenerateIdCallable(): callable |
||
520 | |||
521 | /** |
||
522 | * @inheritdoc |
||
523 | */ |
||
524 | public function setRegenerateIdCallable(callable $callable): SessionFunctionsInterface |
||
530 | |||
531 | /** |
||
532 | * @inheritdoc |
||
533 | */ |
||
534 | public function getRegisterShutdownCallable(): callable |
||
538 | |||
539 | /** |
||
540 | * @inheritdoc |
||
541 | */ |
||
542 | public function setRegisterShutdownCallable(callable $callable): SessionFunctionsInterface |
||
548 | |||
549 | /** |
||
550 | * @inheritdoc |
||
551 | */ |
||
552 | public function getResetCallable(): callable |
||
556 | |||
557 | /** |
||
558 | * @inheritdoc |
||
559 | */ |
||
560 | public function setResetCallable(callable $callable): SessionFunctionsInterface |
||
566 | |||
567 | /** |
||
568 | * @inheritdoc |
||
569 | */ |
||
570 | public function getSavePathCallable(): callable |
||
574 | |||
575 | /** |
||
576 | * @inheritdoc |
||
577 | */ |
||
578 | public function setSavePathCallable(callable $callable): SessionFunctionsInterface |
||
584 | |||
585 | /** |
||
586 | * @inheritdoc |
||
587 | */ |
||
588 | public function getSetCookieParamsCallable(): callable |
||
592 | |||
593 | /** |
||
594 | * @inheritdoc |
||
595 | */ |
||
596 | public function setSetCookieParamsCallable(callable $callable): SessionFunctionsInterface |
||
602 | |||
603 | /** |
||
604 | * @inheritdoc |
||
605 | */ |
||
606 | public function getSetSaveHandlerCallable(): callable |
||
610 | |||
611 | /** |
||
612 | * @inheritdoc |
||
613 | */ |
||
614 | public function setSetSaveHandlerCallable(callable $callable): SessionFunctionsInterface |
||
620 | |||
621 | /** |
||
622 | * @inheritdoc |
||
623 | */ |
||
624 | public function getStartCallable(): callable |
||
628 | |||
629 | /** |
||
630 | * @inheritdoc |
||
631 | */ |
||
632 | public function setStartCallable(callable $callable): SessionFunctionsInterface |
||
638 | |||
639 | /** |
||
640 | * @inheritdoc |
||
641 | */ |
||
642 | public function getStatusCallable(): callable |
||
646 | |||
647 | /** |
||
648 | * @inheritdoc |
||
649 | */ |
||
650 | public function setStatusCallable(callable $callable): SessionFunctionsInterface |
||
656 | |||
657 | /** |
||
658 | * @inheritdoc |
||
659 | */ |
||
660 | public function getUnsetCallable(): callable |
||
664 | |||
665 | /** |
||
666 | * @inheritdoc |
||
667 | */ |
||
668 | public function setUnsetCallable(callable $callable): SessionFunctionsInterface |
||
674 | |||
675 | /** |
||
676 | * @inheritdoc |
||
677 | */ |
||
678 | public function getWriteCloseCallable(): callable |
||
682 | |||
683 | /** |
||
684 | * @inheritdoc |
||
685 | */ |
||
686 | public function setWriteCloseCallable(callable $callable): SessionFunctionsInterface |
||
692 | } |
||
693 |