Total Complexity | 67 |
Total Lines | 777 |
Duplicated Lines | 0 % |
Changes | 0 |
Complex classes like ProfileData 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.
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 ProfileData, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
34 | class ProfileData |
||
35 | { |
||
36 | /** |
||
37 | * @var bool |
||
38 | */ |
||
39 | protected $accView = false; |
||
40 | /** |
||
41 | * @var bool |
||
42 | */ |
||
43 | protected $accViewPass = false; |
||
44 | /** |
||
45 | * @var bool |
||
46 | */ |
||
47 | protected $accViewHistory = false; |
||
48 | /** |
||
49 | * @var bool |
||
50 | */ |
||
51 | protected $accEdit = false; |
||
52 | /** |
||
53 | * @var bool |
||
54 | */ |
||
55 | protected $accEditPass = false; |
||
56 | /** |
||
57 | * @var bool |
||
58 | */ |
||
59 | protected $accAdd = false; |
||
60 | /** |
||
61 | * @var bool |
||
62 | */ |
||
63 | protected $accDelete = false; |
||
64 | /** |
||
65 | * @var bool |
||
66 | */ |
||
67 | protected $accFiles = false; |
||
68 | /** |
||
69 | * @var bool |
||
70 | */ |
||
71 | protected $accPrivate = false; |
||
72 | /** |
||
73 | * @var bool |
||
74 | */ |
||
75 | protected $accPrivateGroup = false; |
||
76 | /** |
||
77 | * @var bool |
||
78 | */ |
||
79 | protected $accPermission = false; |
||
80 | /** |
||
81 | * @var bool |
||
82 | */ |
||
83 | protected $accPublicLinks = false; |
||
84 | /** |
||
85 | * @var bool |
||
86 | */ |
||
87 | protected $accGlobalSearch = false; |
||
88 | /** |
||
89 | * @var bool |
||
90 | */ |
||
91 | protected $configGeneral = false; |
||
92 | /** |
||
93 | * @var bool |
||
94 | */ |
||
95 | protected $configEncryption = false; |
||
96 | /** |
||
97 | * @var bool |
||
98 | */ |
||
99 | protected $configBackup = false; |
||
100 | /** |
||
101 | * @var bool |
||
102 | */ |
||
103 | protected $configImport = false; |
||
104 | /** |
||
105 | * @var bool |
||
106 | */ |
||
107 | protected $mgmUsers = false; |
||
108 | /** |
||
109 | * @var bool |
||
110 | */ |
||
111 | protected $mgmGroups = false; |
||
112 | /** |
||
113 | * @var bool |
||
114 | */ |
||
115 | protected $mgmProfiles = false; |
||
116 | /** |
||
117 | * @var bool |
||
118 | */ |
||
119 | protected $mgmCategories = false; |
||
120 | /** |
||
121 | * @var bool |
||
122 | */ |
||
123 | protected $mgmCustomers = false; |
||
124 | /** |
||
125 | * @var bool |
||
126 | */ |
||
127 | protected $mgmApiTokens = false; |
||
128 | /** |
||
129 | * @var bool |
||
130 | */ |
||
131 | protected $mgmApiOnlyUser = false; |
||
132 | /** |
||
133 | * @var bool |
||
134 | */ |
||
135 | protected $mgmPublicLinks = false; |
||
136 | /** |
||
137 | * @var bool |
||
138 | */ |
||
139 | protected $mgmAccounts = false; |
||
140 | /** |
||
141 | * @var bool |
||
142 | */ |
||
143 | protected $mgmTags = false; |
||
144 | /** |
||
145 | * @var bool |
||
146 | */ |
||
147 | protected $mgmFiles = false; |
||
148 | /** |
||
149 | * @var bool |
||
150 | */ |
||
151 | protected $mgmItemsPreset = false; |
||
152 | /** |
||
153 | * @var bool |
||
154 | */ |
||
155 | protected $evl = false; |
||
156 | /** |
||
157 | * @var bool |
||
158 | */ |
||
159 | protected $mgmCustomFields = false; |
||
160 | |||
161 | /** |
||
162 | * @return boolean |
||
163 | */ |
||
164 | public function isAccView() |
||
165 | { |
||
166 | return $this->accView; |
||
167 | } |
||
168 | |||
169 | /** |
||
170 | * @param boolean $accView |
||
171 | * |
||
172 | * @return ProfileData |
||
173 | */ |
||
174 | public function setAccView($accView) |
||
175 | { |
||
176 | $this->accView = $accView; |
||
177 | |||
178 | return $this; |
||
179 | } |
||
180 | |||
181 | /** |
||
182 | * @return boolean |
||
183 | */ |
||
184 | public function isAccViewPass() |
||
185 | { |
||
186 | return $this->accViewPass; |
||
187 | } |
||
188 | |||
189 | /** |
||
190 | * @param boolean $accViewPass |
||
191 | * |
||
192 | * @return ProfileData |
||
193 | */ |
||
194 | public function setAccViewPass($accViewPass) |
||
195 | { |
||
196 | $this->accViewPass = $accViewPass; |
||
197 | |||
198 | return $this; |
||
199 | } |
||
200 | |||
201 | /** |
||
202 | * @return boolean |
||
203 | */ |
||
204 | public function isAccViewHistory() |
||
205 | { |
||
206 | return $this->accViewHistory; |
||
207 | } |
||
208 | |||
209 | /** |
||
210 | * @param boolean $accViewHistory |
||
211 | * |
||
212 | * @return ProfileData |
||
213 | */ |
||
214 | public function setAccViewHistory($accViewHistory) |
||
215 | { |
||
216 | $this->accViewHistory = $accViewHistory; |
||
217 | |||
218 | return $this; |
||
219 | } |
||
220 | |||
221 | /** |
||
222 | * @return boolean |
||
223 | */ |
||
224 | public function isAccEdit() |
||
225 | { |
||
226 | return $this->accEdit; |
||
227 | } |
||
228 | |||
229 | /** |
||
230 | * @param boolean $accEdit |
||
231 | * |
||
232 | * @return ProfileData |
||
233 | */ |
||
234 | public function setAccEdit($accEdit) |
||
235 | { |
||
236 | $this->accEdit = $accEdit; |
||
237 | |||
238 | return $this; |
||
239 | } |
||
240 | |||
241 | /** |
||
242 | * @return boolean |
||
243 | */ |
||
244 | public function isAccEditPass() |
||
245 | { |
||
246 | return $this->accEditPass; |
||
247 | } |
||
248 | |||
249 | /** |
||
250 | * @param boolean $accEditPass |
||
251 | * |
||
252 | * @return ProfileData |
||
253 | */ |
||
254 | public function setAccEditPass($accEditPass) |
||
255 | { |
||
256 | $this->accEditPass = $accEditPass; |
||
257 | |||
258 | return $this; |
||
259 | } |
||
260 | |||
261 | /** |
||
262 | * @return boolean |
||
263 | */ |
||
264 | public function isAccAdd() |
||
265 | { |
||
266 | return $this->accAdd; |
||
267 | } |
||
268 | |||
269 | /** |
||
270 | * @param boolean $accAdd |
||
271 | * |
||
272 | * @return ProfileData |
||
273 | */ |
||
274 | public function setAccAdd($accAdd) |
||
275 | { |
||
276 | $this->accAdd = $accAdd; |
||
277 | |||
278 | return $this; |
||
279 | } |
||
280 | |||
281 | /** |
||
282 | * @return boolean |
||
283 | */ |
||
284 | public function isAccDelete() |
||
285 | { |
||
286 | return $this->accDelete; |
||
287 | } |
||
288 | |||
289 | /** |
||
290 | * @param boolean $accDelete |
||
291 | * |
||
292 | * @return ProfileData |
||
293 | */ |
||
294 | public function setAccDelete($accDelete) |
||
295 | { |
||
296 | $this->accDelete = $accDelete; |
||
297 | |||
298 | return $this; |
||
299 | } |
||
300 | |||
301 | /** |
||
302 | * @return boolean |
||
303 | */ |
||
304 | public function isAccFiles() |
||
305 | { |
||
306 | return $this->accFiles; |
||
307 | } |
||
308 | |||
309 | /** |
||
310 | * @param boolean $accFiles |
||
311 | * |
||
312 | * @return ProfileData |
||
313 | */ |
||
314 | public function setAccFiles($accFiles) |
||
315 | { |
||
316 | $this->accFiles = $accFiles; |
||
317 | |||
318 | return $this; |
||
319 | } |
||
320 | |||
321 | /** |
||
322 | * @return boolean |
||
323 | */ |
||
324 | public function isAccPublicLinks() |
||
325 | { |
||
326 | return $this->accPublicLinks; |
||
327 | } |
||
328 | |||
329 | /** |
||
330 | * @param boolean $accPublicLinks |
||
331 | * |
||
332 | * @return ProfileData |
||
333 | */ |
||
334 | public function setAccPublicLinks($accPublicLinks) |
||
335 | { |
||
336 | $this->accPublicLinks = $accPublicLinks; |
||
337 | |||
338 | return $this; |
||
339 | } |
||
340 | |||
341 | /** |
||
342 | * @return boolean |
||
343 | */ |
||
344 | public function isConfigGeneral() |
||
345 | { |
||
346 | return $this->configGeneral; |
||
347 | } |
||
348 | |||
349 | /** |
||
350 | * @param boolean $configGeneral |
||
351 | * |
||
352 | * @return ProfileData |
||
353 | */ |
||
354 | public function setConfigGeneral($configGeneral) |
||
355 | { |
||
356 | $this->configGeneral = $configGeneral; |
||
357 | |||
358 | return $this; |
||
359 | } |
||
360 | |||
361 | /** |
||
362 | * @return boolean |
||
363 | */ |
||
364 | public function isConfigEncryption() |
||
365 | { |
||
366 | return $this->configEncryption; |
||
367 | } |
||
368 | |||
369 | /** |
||
370 | * @param boolean $configEncryption |
||
371 | * |
||
372 | * @return ProfileData |
||
373 | */ |
||
374 | public function setConfigEncryption($configEncryption) |
||
375 | { |
||
376 | $this->configEncryption = $configEncryption; |
||
377 | |||
378 | return $this; |
||
379 | } |
||
380 | |||
381 | /** |
||
382 | * @return boolean |
||
383 | */ |
||
384 | public function isConfigBackup() |
||
385 | { |
||
386 | return $this->configBackup; |
||
387 | } |
||
388 | |||
389 | /** |
||
390 | * @param boolean $configBackup |
||
391 | * |
||
392 | * @return ProfileData |
||
393 | */ |
||
394 | public function setConfigBackup($configBackup) |
||
395 | { |
||
396 | $this->configBackup = $configBackup; |
||
397 | |||
398 | return $this; |
||
399 | } |
||
400 | |||
401 | /** |
||
402 | * @return boolean |
||
403 | */ |
||
404 | public function isConfigImport() |
||
405 | { |
||
406 | return $this->configImport; |
||
407 | } |
||
408 | |||
409 | /** |
||
410 | * @param boolean $configImport |
||
411 | * |
||
412 | * @return ProfileData |
||
413 | */ |
||
414 | public function setConfigImport($configImport) |
||
415 | { |
||
416 | $this->configImport = $configImport; |
||
417 | |||
418 | return $this; |
||
419 | } |
||
420 | |||
421 | /** |
||
422 | * @return boolean |
||
423 | */ |
||
424 | public function isMgmUsers() |
||
425 | { |
||
426 | return $this->mgmUsers; |
||
427 | } |
||
428 | |||
429 | /** |
||
430 | * @param boolean $mgmUsers |
||
431 | * |
||
432 | * @return ProfileData |
||
433 | */ |
||
434 | public function setMgmUsers($mgmUsers) |
||
435 | { |
||
436 | $this->mgmUsers = $mgmUsers; |
||
437 | |||
438 | return $this; |
||
439 | } |
||
440 | |||
441 | /** |
||
442 | * @return boolean |
||
443 | */ |
||
444 | public function isMgmGroups() |
||
445 | { |
||
446 | return $this->mgmGroups; |
||
447 | } |
||
448 | |||
449 | /** |
||
450 | * @param boolean $mgmGroups |
||
451 | * |
||
452 | * @return ProfileData |
||
453 | */ |
||
454 | public function setMgmGroups($mgmGroups) |
||
455 | { |
||
456 | $this->mgmGroups = $mgmGroups; |
||
457 | |||
458 | return $this; |
||
459 | } |
||
460 | |||
461 | /** |
||
462 | * @return boolean |
||
463 | */ |
||
464 | public function isMgmProfiles() |
||
465 | { |
||
466 | return $this->mgmProfiles; |
||
467 | } |
||
468 | |||
469 | /** |
||
470 | * @param boolean $mgmProfiles |
||
471 | * |
||
472 | * @return ProfileData |
||
473 | */ |
||
474 | public function setMgmProfiles($mgmProfiles) |
||
475 | { |
||
476 | $this->mgmProfiles = $mgmProfiles; |
||
477 | |||
478 | return $this; |
||
479 | } |
||
480 | |||
481 | /** |
||
482 | * @return boolean |
||
483 | */ |
||
484 | public function isMgmCategories() |
||
485 | { |
||
486 | return $this->mgmCategories; |
||
487 | } |
||
488 | |||
489 | /** |
||
490 | * @param boolean $mgmCategories |
||
491 | * |
||
492 | * @return ProfileData |
||
493 | */ |
||
494 | public function setMgmCategories($mgmCategories) |
||
495 | { |
||
496 | $this->mgmCategories = $mgmCategories; |
||
497 | |||
498 | return $this; |
||
499 | } |
||
500 | |||
501 | /** |
||
502 | * @return boolean |
||
503 | */ |
||
504 | public function isMgmCustomers() |
||
505 | { |
||
506 | return $this->mgmCustomers; |
||
507 | } |
||
508 | |||
509 | /** |
||
510 | * @param boolean $mgmCustomers |
||
511 | * |
||
512 | * @return ProfileData |
||
513 | */ |
||
514 | public function setMgmCustomers($mgmCustomers) |
||
515 | { |
||
516 | $this->mgmCustomers = $mgmCustomers; |
||
517 | |||
518 | return $this; |
||
519 | } |
||
520 | |||
521 | /** |
||
522 | * @return boolean |
||
523 | */ |
||
524 | public function isMgmApiTokens() |
||
525 | { |
||
526 | return $this->mgmApiTokens; |
||
527 | } |
||
528 | |||
529 | /** |
||
530 | * @param boolean $mgmApiTokens |
||
531 | * |
||
532 | * @return ProfileData |
||
533 | */ |
||
534 | public function setMgmApiTokens($mgmApiTokens) |
||
535 | { |
||
536 | $this->mgmApiTokens = $mgmApiTokens; |
||
537 | |||
538 | return $this; |
||
539 | } |
||
540 | |||
541 | /** |
||
542 | * @return boolean |
||
543 | */ |
||
544 | public function isMgmPublicLinks() |
||
545 | { |
||
546 | return $this->mgmPublicLinks; |
||
547 | } |
||
548 | |||
549 | /** |
||
550 | * @param boolean $mgmPublicLinks |
||
551 | * |
||
552 | * @return ProfileData |
||
553 | */ |
||
554 | public function setMgmPublicLinks($mgmPublicLinks) |
||
555 | { |
||
556 | $this->mgmPublicLinks = $mgmPublicLinks; |
||
557 | |||
558 | return $this; |
||
559 | } |
||
560 | |||
561 | /** |
||
562 | * @return boolean |
||
563 | */ |
||
564 | public function isEvl() |
||
567 | } |
||
568 | |||
569 | /** |
||
570 | * @param boolean $evl |
||
571 | * |
||
572 | * @return ProfileData |
||
573 | */ |
||
574 | public function setEvl($evl) |
||
575 | { |
||
576 | $this->evl = $evl; |
||
577 | |||
578 | return $this; |
||
579 | } |
||
580 | |||
581 | /** |
||
582 | * @return boolean |
||
583 | */ |
||
584 | public function isMgmCustomFields() |
||
585 | { |
||
586 | return $this->mgmCustomFields; |
||
587 | } |
||
588 | |||
589 | /** |
||
590 | * @param boolean $mgmCustomFields |
||
591 | * |
||
592 | * @return ProfileData |
||
593 | */ |
||
594 | public function setMgmCustomFields($mgmCustomFields) |
||
595 | { |
||
596 | $this->mgmCustomFields = $mgmCustomFields; |
||
597 | |||
598 | return $this; |
||
599 | } |
||
600 | |||
601 | /** |
||
602 | * unserialize() checks for the presence of a function with the magic name __wakeup. |
||
603 | * If present, this function can reconstruct any resources that the object may have. |
||
604 | * The intended use of __wakeup is to reestablish any database connections that may have been lost during |
||
605 | * serialization and perform other reinitialization tasks. |
||
606 | * |
||
607 | * @return void |
||
608 | * @link http://php.net/manual/en/language.oop5.magic.php#language.oop5.magic.sleep |
||
609 | */ |
||
610 | public function __wakeup() |
||
611 | { |
||
612 | // Para realizar la conversión de nombre de propiedades que empiezan por _ |
||
613 | foreach (get_object_vars($this) as $name => $value) { |
||
614 | if ($name[0] === '_') { |
||
615 | $newName = substr($name, 1); |
||
616 | $this->$newName = $value; |
||
617 | } |
||
618 | } |
||
619 | } |
||
620 | |||
621 | /** |
||
622 | * @return boolean |
||
623 | */ |
||
624 | public function isAccPrivate() |
||
625 | { |
||
626 | return $this->accPrivate; |
||
627 | } |
||
628 | |||
629 | /** |
||
630 | * @param boolean $accPrivate |
||
631 | * |
||
632 | * @return ProfileData |
||
633 | */ |
||
634 | public function setAccPrivate($accPrivate) |
||
635 | { |
||
636 | $this->accPrivate = $accPrivate; |
||
637 | |||
638 | return $this; |
||
639 | } |
||
640 | |||
641 | /** |
||
642 | * @return boolean |
||
643 | */ |
||
644 | public function isAccPermission() |
||
645 | { |
||
646 | return $this->accPermission; |
||
647 | } |
||
648 | |||
649 | /** |
||
650 | * @param boolean $accPermission |
||
651 | * |
||
652 | * @return ProfileData |
||
653 | */ |
||
654 | public function setAccPermission($accPermission) |
||
655 | { |
||
656 | $this->accPermission = $accPermission; |
||
657 | |||
658 | return $this; |
||
659 | } |
||
660 | |||
661 | /** |
||
662 | * @return boolean |
||
663 | */ |
||
664 | public function isMgmAccounts() |
||
667 | } |
||
668 | |||
669 | /** |
||
670 | * @param boolean $mgmAccounts |
||
671 | * |
||
672 | * @return ProfileData |
||
673 | */ |
||
674 | public function setMgmAccounts($mgmAccounts) |
||
675 | { |
||
676 | $this->mgmAccounts = $mgmAccounts; |
||
677 | |||
678 | return $this; |
||
679 | } |
||
680 | |||
681 | /** |
||
682 | * @return boolean |
||
683 | */ |
||
684 | public function isMgmTags() |
||
685 | { |
||
686 | return $this->mgmTags; |
||
687 | } |
||
688 | |||
689 | /** |
||
690 | * @param boolean $mgmTags |
||
691 | * |
||
692 | * @return ProfileData |
||
693 | */ |
||
694 | public function setMgmTags($mgmTags) |
||
695 | { |
||
696 | $this->mgmTags = $mgmTags; |
||
697 | |||
698 | return $this; |
||
699 | } |
||
700 | |||
701 | /** |
||
702 | * @return boolean |
||
703 | */ |
||
704 | public function isMgmFiles() |
||
705 | { |
||
706 | return $this->mgmFiles; |
||
707 | } |
||
708 | |||
709 | /** |
||
710 | * @param boolean $mgmFiles |
||
711 | * |
||
712 | * @return ProfileData |
||
713 | */ |
||
714 | public function setMgmFiles($mgmFiles) |
||
715 | { |
||
716 | $this->mgmFiles = $mgmFiles; |
||
717 | |||
718 | return $this; |
||
719 | } |
||
720 | |||
721 | /** |
||
722 | * @return boolean |
||
723 | */ |
||
724 | public function isAccGlobalSearch() |
||
725 | { |
||
726 | return $this->accGlobalSearch; |
||
727 | } |
||
728 | |||
729 | /** |
||
730 | * @param boolean $accGlobalSearch |
||
731 | * |
||
732 | * @return ProfileData |
||
733 | */ |
||
734 | public function setAccGlobalSearch($accGlobalSearch) |
||
735 | { |
||
736 | $this->accGlobalSearch = $accGlobalSearch; |
||
737 | |||
738 | return $this; |
||
739 | } |
||
740 | |||
741 | /** |
||
742 | * @return bool |
||
743 | */ |
||
744 | public function isAccPrivateGroup() |
||
745 | { |
||
746 | return $this->accPrivateGroup; |
||
747 | } |
||
748 | |||
749 | /** |
||
750 | * @param bool $accPrivateGroup |
||
751 | * |
||
752 | * @return ProfileData |
||
753 | */ |
||
754 | public function setAccPrivateGroup($accPrivateGroup) |
||
759 | } |
||
760 | |||
761 | /** |
||
762 | * @return boolean |
||
763 | */ |
||
764 | public function isMgmApiOnlyUser() |
||
765 | { |
||
766 | return $this->mgmApiOnlyUser; |
||
767 | } |
||
768 | |||
769 | /** |
||
770 | * @param boolean $mgmApiOnlyUser |
||
771 | * |
||
772 | * @return ProfileData |
||
773 | */ |
||
774 | public function setMgmApiOnlyUser($mgmApiOnlyUser) |
||
775 | { |
||
776 | $this->mgmApiOnlyUser = $mgmApiOnlyUser; |
||
777 | |||
778 | return $this; |
||
779 | } |
||
780 | |||
781 | /** |
||
782 | * @return $this |
||
783 | */ |
||
784 | public function reset() |
||
785 | { |
||
786 | foreach ($this as $property => $value) { |
||
787 | $this->{$property} = false; |
||
788 | } |
||
789 | |||
790 | return $this; |
||
791 | } |
||
792 | |||
793 | /** |
||
794 | * @return bool |
||
795 | */ |
||
796 | public function isMgmItemsPreset(): bool |
||
797 | { |
||
798 | return $this->mgmItemsPreset; |
||
799 | } |
||
800 | |||
801 | /** |
||
802 | * @param bool $mgmItemsPreset |
||
803 | * |
||
804 | * @return ProfileData |
||
805 | */ |
||
806 | public function setMgmItemsPreset(bool $mgmItemsPreset) |
||
811 | } |
||
812 | } |