Complex classes like CLp 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 CLp, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
19 | class CLp |
||
20 | { |
||
21 | /** |
||
22 | * @var integer |
||
23 | * |
||
24 | * @ORM\Column(name="iid", type="integer") |
||
25 | * @ORM\Id |
||
26 | * @ORM\GeneratedValue |
||
27 | */ |
||
28 | private $iid; |
||
|
|||
29 | |||
30 | /** |
||
31 | * @var integer |
||
32 | * |
||
33 | * @ORM\Column(name="c_id", type="integer") |
||
34 | */ |
||
35 | private $cId; |
||
36 | |||
37 | /** |
||
38 | * @var integer |
||
39 | * |
||
40 | * @ORM\Column(name="id", type="integer", nullable=true) |
||
41 | */ |
||
42 | private $id; |
||
43 | |||
44 | /** |
||
45 | * @var integer |
||
46 | * |
||
47 | * @ORM\Column(name="lp_type", type="integer", nullable=false) |
||
48 | */ |
||
49 | private $lpType; |
||
50 | |||
51 | /** |
||
52 | * @var string |
||
53 | * |
||
54 | * @ORM\Column(name="name", type="string", length=255, nullable=false) |
||
55 | */ |
||
56 | private $name; |
||
57 | |||
58 | /** |
||
59 | * @var string |
||
60 | * |
||
61 | * @ORM\Column(name="ref", type="text", nullable=true) |
||
62 | */ |
||
63 | private $ref; |
||
64 | |||
65 | /** |
||
66 | * @var string |
||
67 | * |
||
68 | * @ORM\Column(name="description", type="text", nullable=true) |
||
69 | */ |
||
70 | private $description; |
||
71 | |||
72 | /** |
||
73 | * @var string |
||
74 | * |
||
75 | * @ORM\Column(name="path", type="text", nullable=false) |
||
76 | */ |
||
77 | private $path; |
||
78 | |||
79 | /** |
||
80 | * @var boolean |
||
81 | * |
||
82 | * @ORM\Column(name="force_commit", type="boolean", nullable=false) |
||
83 | */ |
||
84 | private $forceCommit; |
||
85 | |||
86 | /** |
||
87 | * @var string |
||
88 | * |
||
89 | * @ORM\Column(name="default_view_mod", type="string", length=32, nullable=false, options={"default":"embedded"}) |
||
90 | */ |
||
91 | private $defaultViewMod; |
||
92 | |||
93 | /** |
||
94 | * @var string |
||
95 | * |
||
96 | * @ORM\Column(name="default_encoding", type="string", length=32, nullable=false, options={"default":"UTF-8"}) |
||
97 | */ |
||
98 | private $defaultEncoding; |
||
99 | |||
100 | /** |
||
101 | * @var integer |
||
102 | * |
||
103 | * @ORM\Column(name="display_order", type="integer", nullable=false, options={"default":"0"}) |
||
104 | */ |
||
105 | private $displayOrder; |
||
106 | |||
107 | /** |
||
108 | * @var string |
||
109 | * |
||
110 | * @ORM\Column(name="content_maker", type="text", nullable=false) |
||
111 | */ |
||
112 | private $contentMaker; |
||
113 | |||
114 | /** |
||
115 | * @var string |
||
116 | * |
||
117 | * @ORM\Column(name="content_local", type="string", length=32, nullable=false, options={"default":"local"}) |
||
118 | */ |
||
119 | private $contentLocal; |
||
120 | |||
121 | /** |
||
122 | * @var string |
||
123 | * |
||
124 | * @ORM\Column(name="content_license", type="text", nullable=false) |
||
125 | */ |
||
126 | private $contentLicense; |
||
127 | |||
128 | /** |
||
129 | * @var boolean |
||
130 | * |
||
131 | * @ORM\Column(name="prevent_reinit", type="boolean", nullable=false, options={"default":"1"}) |
||
132 | */ |
||
133 | private $preventReinit; |
||
134 | |||
135 | /** |
||
136 | * @var string |
||
137 | * |
||
138 | * @ORM\Column(name="js_lib", type="text", nullable=false) |
||
139 | */ |
||
140 | private $jsLib; |
||
141 | |||
142 | /** |
||
143 | * @var boolean |
||
144 | * |
||
145 | * @ORM\Column(name="debug", type="boolean", nullable=false) |
||
146 | */ |
||
147 | private $debug; |
||
148 | |||
149 | /** |
||
150 | * @var string |
||
151 | * |
||
152 | * @ORM\Column(name="theme", type="string", length=255, nullable=false) |
||
153 | */ |
||
154 | private $theme; |
||
155 | |||
156 | /** |
||
157 | * @var string |
||
158 | * |
||
159 | * @ORM\Column(name="preview_image", type="string", length=255, nullable=false) |
||
160 | */ |
||
161 | private $previewImage; |
||
162 | |||
163 | /** |
||
164 | * @var string |
||
165 | * |
||
166 | * @ORM\Column(name="author", type="string", length=255, nullable=false) |
||
167 | */ |
||
168 | private $author; |
||
169 | |||
170 | /** |
||
171 | * @var integer |
||
172 | * |
||
173 | * @ORM\Column(name="session_id", type="integer", nullable=false) |
||
174 | */ |
||
175 | private $sessionId; |
||
176 | |||
177 | /** |
||
178 | * @var integer |
||
179 | * |
||
180 | * @ORM\Column(name="prerequisite", type="integer", nullable=false) |
||
181 | */ |
||
182 | private $prerequisite; |
||
183 | |||
184 | /** |
||
185 | * @var boolean |
||
186 | * |
||
187 | * @ORM\Column(name="hide_toc_frame", type="boolean", nullable=false) |
||
188 | */ |
||
189 | private $hideTocFrame; |
||
190 | |||
191 | /** |
||
192 | * @var boolean |
||
193 | * |
||
194 | * @ORM\Column(name="seriousgame_mode", type="boolean", nullable=false) |
||
195 | */ |
||
196 | private $seriousgameMode; |
||
197 | |||
198 | /** |
||
199 | * @var integer |
||
200 | * |
||
201 | * @ORM\Column(name="use_max_score", type="integer", nullable=false, options={"default":"1"}) |
||
202 | */ |
||
203 | private $useMaxScore; |
||
204 | |||
205 | /** |
||
206 | * @var integer |
||
207 | * |
||
208 | * @ORM\Column(name="autolaunch", type="integer", nullable=false) |
||
209 | */ |
||
210 | private $autolaunch; |
||
211 | |||
212 | /** |
||
213 | * @var integer |
||
214 | * |
||
215 | * @ORM\Column(name="category_id", type="integer", precision=0, scale=0, nullable=false, unique=false) |
||
216 | */ |
||
217 | private $categoryId; |
||
218 | |||
219 | /** |
||
220 | * @var integer |
||
221 | * |
||
222 | * @ORM\Column(name="max_attempts", type="integer", nullable=false) |
||
223 | */ |
||
224 | private $maxAttempts; |
||
225 | |||
226 | /** |
||
227 | * @var integer |
||
228 | * |
||
229 | * @ORM\Column(name="subscribe_users", type="integer", nullable=false) |
||
230 | */ |
||
231 | private $subscribeUsers; |
||
232 | |||
233 | /** |
||
234 | * @var \DateTime |
||
235 | * |
||
236 | * @ORM\Column(name="created_on", type="datetime", nullable=false) |
||
237 | */ |
||
238 | private $createdOn; |
||
239 | |||
240 | /** |
||
241 | * @var \DateTime |
||
242 | * |
||
243 | * @ORM\Column(name="modified_on", type="datetime", nullable=false) |
||
244 | */ |
||
245 | private $modifiedOn; |
||
246 | |||
247 | /** |
||
248 | * @var \DateTime |
||
249 | * |
||
250 | * @ORM\Column(name="publicated_on", type="datetime", nullable=true) |
||
251 | */ |
||
252 | private $publicatedOn; |
||
253 | |||
254 | /** |
||
255 | * @var \DateTime |
||
256 | * |
||
257 | * @ORM\Column(name="expired_on", type="datetime", nullable=true) |
||
258 | */ |
||
259 | private $expiredOn; |
||
260 | |||
261 | /** |
||
262 | * @var \DateTime |
||
263 | * |
||
264 | * @ORM\Column(name="accumulate_scorm_time", type="boolean", nullable=false) |
||
265 | */ |
||
266 | private $accumulateScormTime; |
||
267 | |||
268 | /** |
||
269 | * Constructor |
||
270 | */ |
||
271 | public function __construct() |
||
281 | |||
282 | /** |
||
283 | * Set lpType |
||
284 | * |
||
285 | * @param integer $lpType |
||
286 | * @return CLp |
||
287 | */ |
||
288 | public function setLpType($lpType) |
||
294 | |||
295 | /** |
||
296 | * Get lpType |
||
297 | * |
||
298 | * @return integer |
||
299 | */ |
||
300 | public function getLpType() |
||
304 | |||
305 | /** |
||
306 | * Set name |
||
307 | * |
||
308 | * @param string $name |
||
309 | * @return CLp |
||
310 | */ |
||
311 | public function setName($name) |
||
317 | |||
318 | /** |
||
319 | * Get name |
||
320 | * |
||
321 | * @return string |
||
322 | */ |
||
323 | public function getName() |
||
327 | |||
328 | /** |
||
329 | * Set ref |
||
330 | * |
||
331 | * @param string $ref |
||
332 | * @return CLp |
||
333 | */ |
||
334 | public function setRef($ref) |
||
340 | |||
341 | /** |
||
342 | * Get ref |
||
343 | * |
||
344 | * @return string |
||
345 | */ |
||
346 | public function getRef() |
||
350 | |||
351 | /** |
||
352 | * Set description |
||
353 | * |
||
354 | * @param string $description |
||
355 | * @return CLp |
||
356 | */ |
||
357 | public function setDescription($description) |
||
363 | |||
364 | /** |
||
365 | * Get description |
||
366 | * |
||
367 | * @return string |
||
368 | */ |
||
369 | public function getDescription() |
||
373 | |||
374 | /** |
||
375 | * Set path |
||
376 | * |
||
377 | * @param string $path |
||
378 | * @return CLp |
||
379 | */ |
||
380 | public function setPath($path) |
||
386 | |||
387 | /** |
||
388 | * Get path |
||
389 | * |
||
390 | * @return string |
||
391 | */ |
||
392 | public function getPath() |
||
396 | |||
397 | /** |
||
398 | * Set forceCommit |
||
399 | * |
||
400 | * @param boolean $forceCommit |
||
401 | * @return CLp |
||
402 | */ |
||
403 | public function setForceCommit($forceCommit) |
||
409 | |||
410 | /** |
||
411 | * Get forceCommit |
||
412 | * |
||
413 | * @return boolean |
||
414 | */ |
||
415 | public function getForceCommit() |
||
419 | |||
420 | /** |
||
421 | * Set defaultViewMod |
||
422 | * |
||
423 | * @param string $defaultViewMod |
||
424 | * @return CLp |
||
425 | */ |
||
426 | public function setDefaultViewMod($defaultViewMod) |
||
432 | |||
433 | /** |
||
434 | * Get defaultViewMod |
||
435 | * |
||
436 | * @return string |
||
437 | */ |
||
438 | public function getDefaultViewMod() |
||
442 | |||
443 | /** |
||
444 | * Set defaultEncoding |
||
445 | * |
||
446 | * @param string $defaultEncoding |
||
447 | * @return CLp |
||
448 | */ |
||
449 | public function setDefaultEncoding($defaultEncoding) |
||
455 | |||
456 | /** |
||
457 | * Get defaultEncoding |
||
458 | * |
||
459 | * @return string |
||
460 | */ |
||
461 | public function getDefaultEncoding() |
||
465 | |||
466 | /** |
||
467 | * Set displayOrder |
||
468 | * |
||
469 | * @param integer $displayOrder |
||
470 | * @return CLp |
||
471 | */ |
||
472 | public function setDisplayOrder($displayOrder) |
||
478 | |||
479 | /** |
||
480 | * Get displayOrder |
||
481 | * |
||
482 | * @return integer |
||
483 | */ |
||
484 | public function getDisplayOrder() |
||
488 | |||
489 | /** |
||
490 | * Set contentMaker |
||
491 | * |
||
492 | * @param string $contentMaker |
||
493 | * @return CLp |
||
494 | */ |
||
495 | public function setContentMaker($contentMaker) |
||
501 | |||
502 | /** |
||
503 | * Get contentMaker |
||
504 | * |
||
505 | * @return string |
||
506 | */ |
||
507 | public function getContentMaker() |
||
511 | |||
512 | /** |
||
513 | * Set contentLocal |
||
514 | * |
||
515 | * @param string $contentLocal |
||
516 | * @return CLp |
||
517 | */ |
||
518 | public function setContentLocal($contentLocal) |
||
524 | |||
525 | /** |
||
526 | * Get contentLocal |
||
527 | * |
||
528 | * @return string |
||
529 | */ |
||
530 | public function getContentLocal() |
||
534 | |||
535 | /** |
||
536 | * Set contentLicense |
||
537 | * |
||
538 | * @param string $contentLicense |
||
539 | * @return CLp |
||
540 | */ |
||
541 | public function setContentLicense($contentLicense) |
||
547 | |||
548 | /** |
||
549 | * Get contentLicense |
||
550 | * |
||
551 | * @return string |
||
552 | */ |
||
553 | public function getContentLicense() |
||
557 | |||
558 | /** |
||
559 | * Set preventReinit |
||
560 | * |
||
561 | * @param boolean $preventReinit |
||
562 | * @return CLp |
||
563 | */ |
||
564 | public function setPreventReinit($preventReinit) |
||
570 | |||
571 | /** |
||
572 | * Get preventReinit |
||
573 | * |
||
574 | * @return boolean |
||
575 | */ |
||
576 | public function getPreventReinit() |
||
580 | |||
581 | /** |
||
582 | * Set jsLib |
||
583 | * |
||
584 | * @param string $jsLib |
||
585 | * @return CLp |
||
586 | */ |
||
587 | public function setJsLib($jsLib) |
||
593 | |||
594 | /** |
||
595 | * Get jsLib |
||
596 | * |
||
597 | * @return string |
||
598 | */ |
||
599 | public function getJsLib() |
||
603 | |||
604 | /** |
||
605 | * Set debug |
||
606 | * |
||
607 | * @param boolean $debug |
||
608 | * @return CLp |
||
609 | */ |
||
610 | public function setDebug($debug) |
||
616 | |||
617 | /** |
||
618 | * Get debug |
||
619 | * |
||
620 | * @return boolean |
||
621 | */ |
||
622 | public function getDebug() |
||
626 | |||
627 | /** |
||
628 | * Set theme |
||
629 | * |
||
630 | * @param string $theme |
||
631 | * @return CLp |
||
632 | */ |
||
633 | public function setTheme($theme) |
||
639 | |||
640 | /** |
||
641 | * Get theme |
||
642 | * |
||
643 | * @return string |
||
644 | */ |
||
645 | public function getTheme() |
||
649 | |||
650 | /** |
||
651 | * Set previewImage |
||
652 | * |
||
653 | * @param string $previewImage |
||
654 | * @return CLp |
||
655 | */ |
||
656 | public function setPreviewImage($previewImage) |
||
662 | |||
663 | /** |
||
664 | * Get previewImage |
||
665 | * |
||
666 | * @return string |
||
667 | */ |
||
668 | public function getPreviewImage() |
||
672 | |||
673 | /** |
||
674 | * Set author |
||
675 | * |
||
676 | * @param string $author |
||
677 | * @return CLp |
||
678 | */ |
||
679 | public function setAuthor($author) |
||
685 | |||
686 | /** |
||
687 | * Get author |
||
688 | * |
||
689 | * @return string |
||
690 | */ |
||
691 | public function getAuthor() |
||
695 | |||
696 | /** |
||
697 | * Set sessionId |
||
698 | * |
||
699 | * @param integer $sessionId |
||
700 | * @return CLp |
||
701 | */ |
||
702 | public function setSessionId($sessionId) |
||
708 | |||
709 | /** |
||
710 | * Get sessionId |
||
711 | * |
||
712 | * @return integer |
||
713 | */ |
||
714 | public function getSessionId() |
||
718 | |||
719 | /** |
||
720 | * Set prerequisite |
||
721 | * |
||
722 | * @param integer $prerequisite |
||
723 | * @return CLp |
||
724 | */ |
||
725 | public function setPrerequisite($prerequisite) |
||
731 | |||
732 | /** |
||
733 | * Get prerequisite |
||
734 | * |
||
735 | * @return integer |
||
736 | */ |
||
737 | public function getPrerequisite() |
||
741 | |||
742 | /** |
||
743 | * Set hideTocFrame |
||
744 | * |
||
745 | * @param boolean $hideTocFrame |
||
746 | * @return CLp |
||
747 | */ |
||
748 | public function setHideTocFrame($hideTocFrame) |
||
754 | |||
755 | /** |
||
756 | * Get hideTocFrame |
||
757 | * |
||
758 | * @return boolean |
||
759 | */ |
||
760 | public function getHideTocFrame() |
||
764 | |||
765 | /** |
||
766 | * Set seriousgameMode |
||
767 | * |
||
768 | * @param boolean $seriousgameMode |
||
769 | * @return CLp |
||
770 | */ |
||
771 | public function setSeriousgameMode($seriousgameMode) |
||
777 | |||
778 | /** |
||
779 | * Get seriousgameMode |
||
780 | * |
||
781 | * @return boolean |
||
782 | */ |
||
783 | public function getSeriousgameMode() |
||
787 | |||
788 | /** |
||
789 | * Set useMaxScore |
||
790 | * |
||
791 | * @param integer $useMaxScore |
||
792 | * @return CLp |
||
793 | */ |
||
794 | public function setUseMaxScore($useMaxScore) |
||
800 | |||
801 | /** |
||
802 | * Get useMaxScore |
||
803 | * |
||
804 | * @return integer |
||
805 | */ |
||
806 | public function getUseMaxScore() |
||
810 | |||
811 | /** |
||
812 | * Set autolaunch |
||
813 | * |
||
814 | * @param integer $autolaunch |
||
815 | * @return CLp |
||
816 | */ |
||
817 | public function setAutolaunch($autolaunch) |
||
823 | |||
824 | /** |
||
825 | * Get autolaunch |
||
826 | * |
||
827 | * @return integer |
||
828 | */ |
||
829 | public function getAutolaunch() |
||
833 | |||
834 | /** |
||
835 | * Set createdOn |
||
836 | * |
||
837 | * @param \DateTime $createdOn |
||
838 | * @return CLp |
||
839 | */ |
||
840 | public function setCreatedOn($createdOn) |
||
846 | |||
847 | /** |
||
848 | * Get createdOn |
||
849 | * |
||
850 | * @return \DateTime |
||
851 | */ |
||
852 | public function getCreatedOn() |
||
856 | |||
857 | /** |
||
858 | * Set modifiedOn |
||
859 | * |
||
860 | * @param \DateTime $modifiedOn |
||
861 | * @return CLp |
||
862 | */ |
||
863 | public function setModifiedOn($modifiedOn) |
||
869 | |||
870 | /** |
||
871 | * Get modifiedOn |
||
872 | * |
||
873 | * @return \DateTime |
||
874 | */ |
||
875 | public function getModifiedOn() |
||
879 | |||
880 | /** |
||
881 | * Set publicatedOn |
||
882 | * |
||
883 | * @param \DateTime $publicatedOn |
||
884 | * @return CLp |
||
885 | */ |
||
886 | public function setPublicatedOn($publicatedOn) |
||
892 | |||
893 | /** |
||
894 | * Get publicatedOn |
||
895 | * |
||
896 | * @return \DateTime |
||
897 | */ |
||
898 | public function getPublicatedOn() |
||
902 | |||
903 | /** |
||
904 | * Set expiredOn |
||
905 | * |
||
906 | * @param \DateTime $expiredOn |
||
907 | * @return CLp |
||
908 | */ |
||
909 | public function setExpiredOn($expiredOn) |
||
915 | |||
916 | /** |
||
917 | * Get expiredOn |
||
918 | * |
||
919 | * @return \DateTime |
||
920 | */ |
||
921 | public function getExpiredOn() |
||
925 | |||
926 | /** |
||
927 | * Set id |
||
928 | * |
||
929 | * @param integer $id |
||
930 | * @return CLp |
||
931 | */ |
||
932 | public function setId($id) |
||
938 | |||
939 | /** |
||
940 | * Get id |
||
941 | * |
||
942 | * @return integer |
||
943 | */ |
||
944 | public function getId() |
||
948 | |||
949 | /** |
||
950 | * Set cId |
||
951 | * |
||
952 | * @param integer $cId |
||
953 | * @return CLp |
||
954 | */ |
||
955 | public function setCId($cId) |
||
961 | |||
962 | /** |
||
963 | * Get cId |
||
964 | * |
||
965 | * @return integer |
||
966 | */ |
||
967 | public function getCId() |
||
971 | |||
972 | /** |
||
973 | * @return int |
||
974 | */ |
||
975 | public function getCategoryId() |
||
979 | |||
980 | /** |
||
981 | * @param int $categoryId |
||
982 | * @return CLp |
||
983 | */ |
||
984 | public function setCategoryId($categoryId) |
||
990 | |||
991 | /** |
||
992 | * @return boolean |
||
993 | */ |
||
994 | public function getAccumulateScormTime() |
||
998 | |||
999 | /** |
||
1000 | * @param boolean $accumulateScormTime |
||
1001 | * @return CLp |
||
1002 | */ |
||
1003 | public function setAccumulateScormTime($accumulateScormTime) |
||
1009 | |||
1010 | } |
||
1011 |
This check marks private properties in classes that are never used. Those properties can be removed.