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