Total Complexity | 72 |
Total Lines | 784 |
Duplicated Lines | 0 % |
Changes | 4 | ||
Bugs | 1 | Features | 0 |
Complex classes like Indi 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 Indi, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
23 | class Indi extends \Gedcom\Record implements Noteable, Objectable, Sourceable |
||
24 | { |
||
25 | /** |
||
26 | * @var string |
||
27 | */ |
||
28 | protected $id; |
||
29 | |||
30 | /** |
||
31 | * @var string |
||
32 | */ |
||
33 | protected $gid; |
||
34 | |||
35 | /** |
||
36 | * @var string |
||
37 | */ |
||
38 | protected $uid; |
||
39 | |||
40 | /** |
||
41 | * @var string |
||
42 | */ |
||
43 | protected $resn; |
||
44 | /** |
||
45 | * @var Indi\Name[] |
||
46 | */ |
||
47 | protected $name = []; |
||
48 | /** |
||
49 | * @var string |
||
50 | */ |
||
51 | protected $sex; |
||
52 | |||
53 | /** |
||
54 | * @var Indi\Even[] |
||
55 | */ |
||
56 | protected $even = []; |
||
57 | /** |
||
58 | * @var Indi\Attr[] |
||
59 | */ |
||
60 | protected $attr = []; |
||
61 | /** |
||
62 | * @var Indi\Bapl |
||
63 | */ |
||
64 | protected $bapl = []; |
||
65 | |||
66 | /** |
||
67 | * @var Indi\Conl |
||
68 | */ |
||
69 | protected $conl = []; |
||
70 | |||
71 | /** |
||
72 | * @var Indi\Endl |
||
73 | */ |
||
74 | protected $endl = []; |
||
75 | |||
76 | /** |
||
77 | * @var Indi\Slgc |
||
78 | */ |
||
79 | protected $slgc = []; |
||
80 | |||
81 | /** |
||
82 | * @var Indi\Famc[] |
||
83 | */ |
||
84 | protected $famc = []; |
||
85 | /** |
||
86 | * @var Indi\Fams[] |
||
87 | */ |
||
88 | protected $fams = []; |
||
89 | /** |
||
90 | * @var string[] |
||
91 | */ |
||
92 | protected $subm = []; |
||
93 | /** |
||
94 | * @var string[] |
||
95 | */ |
||
96 | protected $alia = []; |
||
97 | /** |
||
98 | * @var string[] |
||
99 | */ |
||
100 | protected $anci = []; |
||
101 | /** |
||
102 | * @var string[] |
||
103 | */ |
||
104 | protected $desi = []; |
||
105 | /** |
||
106 | * @var string |
||
107 | */ |
||
108 | protected $rfn; |
||
109 | /** |
||
110 | * @var string |
||
111 | */ |
||
112 | protected $afn; |
||
113 | /** |
||
114 | * @var Refn[] |
||
115 | */ |
||
116 | protected $refn = []; |
||
117 | /** |
||
118 | * @var string |
||
119 | */ |
||
120 | protected $rin; |
||
121 | |||
122 | /** |
||
123 | * @var string |
||
124 | */ |
||
125 | protected $chan; |
||
126 | |||
127 | /** |
||
128 | * @var Indi\Note[] |
||
129 | */ |
||
130 | protected $note = []; |
||
131 | |||
132 | /** |
||
133 | * @var Obje[] |
||
134 | */ |
||
135 | protected $obje = []; |
||
136 | |||
137 | /** |
||
138 | * @var Sour[] |
||
139 | */ |
||
140 | protected $sour = []; |
||
141 | |||
142 | /** |
||
143 | * @var Indi\Asso[] |
||
144 | */ |
||
145 | protected $asso = []; |
||
146 | |||
147 | protected $deathday = []; |
||
148 | |||
149 | protected $birt; |
||
150 | |||
151 | protected $buri; |
||
152 | |||
153 | protected $deat; |
||
154 | |||
155 | protected $chr; |
||
156 | |||
157 | public function setBirt($birt) { |
||
158 | $this->birt = $birt; |
||
159 | } |
||
160 | |||
161 | public function getBirt() { |
||
162 | return $this->birt; |
||
163 | } |
||
164 | |||
165 | public function setBuri($buri) { |
||
166 | $this->buri = $buri; |
||
167 | } |
||
168 | |||
169 | public function getBuri() { |
||
170 | return $this->buri; |
||
171 | } |
||
172 | |||
173 | public function setDeat($deat) { |
||
174 | $this->deat = $deat; |
||
175 | } |
||
176 | |||
177 | public function getDeat() { |
||
178 | return $this->deat; |
||
179 | } |
||
180 | |||
181 | public function setChr($chr) { |
||
182 | $this->chr = $chr; |
||
183 | } |
||
184 | |||
185 | public function getChr() { |
||
186 | return $this->chr; |
||
187 | } |
||
188 | |||
189 | /** |
||
190 | * @param string $id |
||
191 | * |
||
192 | * @return Indi |
||
193 | */ |
||
194 | public function setId($id = '') |
||
195 | { |
||
196 | $this->id = $id; |
||
197 | |||
198 | return $this; |
||
199 | } |
||
200 | |||
201 | /** |
||
202 | * @return string |
||
203 | */ |
||
204 | public function getId() |
||
205 | { |
||
206 | return $this->id; |
||
207 | } |
||
208 | |||
209 | /** |
||
210 | * @param string $id |
||
211 | * |
||
212 | * @return Indi |
||
213 | */ |
||
214 | public function setGid($gid = '') |
||
215 | { |
||
216 | $this->gid = $gid; |
||
217 | |||
218 | return $this; |
||
219 | } |
||
220 | |||
221 | /** |
||
222 | * @return string |
||
223 | */ |
||
224 | public function getGid() |
||
225 | { |
||
226 | return $this->gid; |
||
227 | } |
||
228 | |||
229 | /** |
||
230 | * @param string $uid |
||
231 | * |
||
232 | * @return Indi |
||
233 | */ |
||
234 | public function setUid($uid = '') |
||
235 | { |
||
236 | $this->uid = $uid; |
||
237 | |||
238 | return $this; |
||
239 | } |
||
240 | |||
241 | /** |
||
242 | * @return string |
||
243 | */ |
||
244 | public function getUid() |
||
245 | { |
||
246 | return $this->uid; |
||
247 | } |
||
248 | |||
249 | /** |
||
250 | * @param Indi\Name $name |
||
251 | * |
||
252 | * @return Indi |
||
253 | */ |
||
254 | public function addName($name = []) |
||
255 | { |
||
256 | $this->name[] = $name; |
||
257 | |||
258 | return $this; |
||
259 | } |
||
260 | |||
261 | /** |
||
262 | * @return Indi\Name[] |
||
263 | */ |
||
264 | public function getName() |
||
265 | { |
||
266 | return $this->name; |
||
267 | } |
||
268 | |||
269 | /** |
||
270 | * @param Indi\Attr $attr |
||
271 | * |
||
272 | * @return Indi |
||
273 | */ |
||
274 | public function addAttr($attr = []) |
||
275 | { |
||
276 | $attrName = $attr->getType(); |
||
277 | |||
278 | if (!array_key_exists($attrName, $this->attr)) { |
||
279 | $this->attr[$attrName] = []; |
||
280 | } |
||
281 | |||
282 | $this->attr[$attrName][] = $attr; |
||
283 | |||
284 | return $this; |
||
285 | } |
||
286 | |||
287 | /** |
||
288 | * @return Indi\Attr[] |
||
289 | */ |
||
290 | public function getAllAttr() |
||
291 | { |
||
292 | return $this->attr; |
||
293 | } |
||
294 | |||
295 | /** |
||
296 | * @return Indi\Attr[] |
||
297 | */ |
||
298 | public function getAttr($key = '') |
||
299 | { |
||
300 | if (isset($this->attr[strtoupper($key)])) { |
||
301 | return $this->attr[strtoupper($key)]; |
||
|
|||
302 | } |
||
303 | } |
||
304 | |||
305 | /** |
||
306 | * @param Indi\Even $even |
||
307 | * |
||
308 | * @return Indi |
||
309 | */ |
||
310 | public function addEven($even = []) |
||
311 | { |
||
312 | $evenName = $even->getType(); |
||
313 | |||
314 | if (!array_key_exists($evenName, $this->even)) { |
||
315 | $this->even[$evenName] = []; |
||
316 | } |
||
317 | |||
318 | $this->even[$evenName][] = $even; |
||
319 | |||
320 | return $this; |
||
321 | } |
||
322 | |||
323 | /** |
||
324 | * @return array |
||
325 | */ |
||
326 | public function getAllEven() |
||
327 | { |
||
328 | return $this->even; |
||
329 | } |
||
330 | |||
331 | /** |
||
332 | * @return array |
||
333 | */ |
||
334 | public function getEven($key = '') |
||
335 | { |
||
336 | if (isset($this->even[strtoupper($key)])) { |
||
337 | return $this->even[strtoupper($key)]; |
||
338 | } |
||
339 | } |
||
340 | |||
341 | /** |
||
342 | * @param Indi\Asso $asso |
||
343 | * |
||
344 | * @return Indi |
||
345 | */ |
||
346 | public function addAsso($asso = []) |
||
347 | { |
||
348 | $this->asso[] = $asso; |
||
349 | |||
350 | return $this; |
||
351 | } |
||
352 | |||
353 | /** |
||
354 | * @return array |
||
355 | */ |
||
356 | public function getAsso() |
||
357 | { |
||
358 | return $this->asso; |
||
359 | } |
||
360 | |||
361 | /** |
||
362 | * @param Refn $ref |
||
363 | * |
||
364 | * @return Indi |
||
365 | */ |
||
366 | public function addRefn($ref = []) |
||
367 | { |
||
368 | $this->refn[] = $ref; |
||
369 | |||
370 | return $this; |
||
371 | } |
||
372 | |||
373 | /** |
||
374 | * @return Refn[] |
||
375 | */ |
||
376 | public function getRefn() |
||
377 | { |
||
378 | return $this->refn; |
||
379 | } |
||
380 | |||
381 | /** |
||
382 | * @param \Gedcom\Record\NoteRef $note |
||
383 | * |
||
384 | * @return Indi |
||
385 | */ |
||
386 | public function addNote($note = []) |
||
387 | { |
||
388 | $this->note[] = $note; |
||
389 | |||
390 | return $this; |
||
391 | } |
||
392 | |||
393 | /** |
||
394 | * @return array |
||
395 | */ |
||
396 | public function getNote() |
||
397 | { |
||
398 | return $this->note; |
||
399 | } |
||
400 | |||
401 | /** |
||
402 | * @param ObjeRef $obje |
||
403 | * |
||
404 | * @return Indi |
||
405 | */ |
||
406 | public function addObje($obje = []) |
||
407 | { |
||
408 | $this->obje[] = $obje; |
||
409 | |||
410 | return $this; |
||
411 | } |
||
412 | |||
413 | /** |
||
414 | * @return array |
||
415 | */ |
||
416 | public function getObje() |
||
417 | { |
||
418 | return $this->obje; |
||
419 | } |
||
420 | |||
421 | /** |
||
422 | * @param SourRef $sour |
||
423 | * |
||
424 | * @return Indi |
||
425 | */ |
||
426 | public function addSour($sour = []) |
||
427 | { |
||
428 | $this->sour[] = $sour; |
||
429 | |||
430 | return $this; |
||
431 | } |
||
432 | |||
433 | /** |
||
434 | * @return array |
||
435 | */ |
||
436 | public function getSour() |
||
437 | { |
||
438 | return $this->sour; |
||
439 | } |
||
440 | |||
441 | /** |
||
442 | * @param string $indi |
||
443 | * |
||
444 | * @return Indi |
||
445 | */ |
||
446 | public function addAlia($indi = '') |
||
447 | { |
||
448 | $this->alia[] = $indi; |
||
449 | |||
450 | return $this; |
||
451 | } |
||
452 | |||
453 | /** |
||
454 | * @return array |
||
455 | */ |
||
456 | public function getAlia() |
||
457 | { |
||
458 | return $this->alia; |
||
459 | } |
||
460 | |||
461 | /** |
||
462 | * @param Indi\Famc $famc |
||
463 | * |
||
464 | * @return Indi |
||
465 | */ |
||
466 | public function addFamc($famc = []) |
||
467 | { |
||
468 | $this->famc[] = $famc; |
||
469 | |||
470 | return $this; |
||
471 | } |
||
472 | |||
473 | /** |
||
474 | * @return array |
||
475 | */ |
||
476 | public function getFamc() |
||
477 | { |
||
478 | return $this->famc; |
||
479 | } |
||
480 | |||
481 | /** |
||
482 | * @param Indi\Fams $fams |
||
483 | * |
||
484 | * @return Indi |
||
485 | */ |
||
486 | public function addFams($fams = []) |
||
487 | { |
||
488 | $this->fams[] = $fams; |
||
489 | |||
490 | return $this; |
||
491 | } |
||
492 | |||
493 | /** |
||
494 | * @return array |
||
495 | */ |
||
496 | public function getFams() |
||
497 | { |
||
498 | return $this->fams; |
||
499 | } |
||
500 | |||
501 | /** |
||
502 | * @param string $subm |
||
503 | * |
||
504 | * @return Indi |
||
505 | */ |
||
506 | public function addAnci($subm = '') |
||
507 | { |
||
508 | $this->anci[] = $subm; |
||
509 | |||
510 | return $this; |
||
511 | } |
||
512 | |||
513 | /** |
||
514 | * @return string[] |
||
515 | */ |
||
516 | public function getAnci() |
||
517 | { |
||
518 | return $this->anci; |
||
519 | } |
||
520 | |||
521 | /** |
||
522 | * @param string $subm |
||
523 | * |
||
524 | * @return Indi |
||
525 | */ |
||
526 | public function addDesi($subm = '') |
||
527 | { |
||
528 | $this->desi[] = $subm; |
||
529 | |||
530 | return $this; |
||
531 | } |
||
532 | |||
533 | /** |
||
534 | * @return string[] |
||
535 | */ |
||
536 | public function getDesi() |
||
537 | { |
||
538 | return $this->desi; |
||
539 | } |
||
540 | |||
541 | /** |
||
542 | * @param string $subm |
||
543 | * |
||
544 | * @return Indi |
||
545 | */ |
||
546 | public function addSubm($subm = '') |
||
547 | { |
||
548 | $this->subm[] = $subm; |
||
549 | |||
550 | return $this; |
||
551 | } |
||
552 | |||
553 | /** |
||
554 | * @return string[] |
||
555 | */ |
||
556 | public function getSubm() |
||
557 | { |
||
558 | return $this->subm; |
||
559 | } |
||
560 | |||
561 | /** |
||
562 | * @param string $resn |
||
563 | * |
||
564 | * @return Indi |
||
565 | */ |
||
566 | public function setResn($resn = '') |
||
567 | { |
||
568 | $this->resn = $resn; |
||
569 | |||
570 | return $this; |
||
571 | } |
||
572 | |||
573 | /** |
||
574 | * @return string |
||
575 | */ |
||
576 | public function getResn() |
||
577 | { |
||
578 | return $this->resn; |
||
579 | } |
||
580 | |||
581 | /** |
||
582 | * @param string $sex |
||
583 | * |
||
584 | * @return Indi |
||
585 | */ |
||
586 | public function setSex($sex = '') |
||
587 | { |
||
588 | $this->sex = $sex; |
||
589 | |||
590 | return $this; |
||
591 | } |
||
592 | |||
593 | /** |
||
594 | * @return string |
||
595 | */ |
||
596 | public function getSex() |
||
597 | { |
||
598 | return $this->sex; |
||
599 | } |
||
600 | |||
601 | /** |
||
602 | * @param string $rfn |
||
603 | * |
||
604 | * @return Indi |
||
605 | */ |
||
606 | public function setRfn($rfn = '') |
||
607 | { |
||
608 | $this->rfn = $rfn; |
||
609 | |||
610 | return $this; |
||
611 | } |
||
612 | |||
613 | /** |
||
614 | * @return string |
||
615 | */ |
||
616 | public function getRfn() |
||
617 | { |
||
618 | return $this->rfn; |
||
619 | } |
||
620 | |||
621 | /** |
||
622 | * @param string $afn |
||
623 | * |
||
624 | * @return Indi |
||
625 | */ |
||
626 | public function setAfn($afn = '') |
||
627 | { |
||
628 | $this->afn = $afn; |
||
629 | |||
630 | return $this; |
||
631 | } |
||
632 | |||
633 | /** |
||
634 | * @return string |
||
635 | */ |
||
636 | public function getAfn() |
||
637 | { |
||
638 | return $this->afn; |
||
639 | } |
||
640 | |||
641 | /** |
||
642 | * @param string $chan |
||
643 | * |
||
644 | * @return Indi |
||
645 | */ |
||
646 | public function setChan($chan = null) |
||
647 | { |
||
648 | $this->chan = $chan; |
||
649 | |||
650 | return $this; |
||
651 | } |
||
652 | |||
653 | /** |
||
654 | * @return string |
||
655 | */ |
||
656 | public function getChan() |
||
657 | { |
||
658 | return $this->chan; |
||
659 | } |
||
660 | |||
661 | /** |
||
662 | * @param string $rin |
||
663 | * |
||
664 | * @return Indi |
||
665 | */ |
||
666 | public function setRin($rin = '') |
||
667 | { |
||
668 | $this->rin = $rin; |
||
669 | |||
670 | return $this; |
||
671 | } |
||
672 | |||
673 | /** |
||
674 | * @return string |
||
675 | */ |
||
676 | public function getRin() |
||
679 | } |
||
680 | |||
681 | /** |
||
682 | * @param Indi\Bapl $bapl |
||
683 | * |
||
684 | * @return Indi |
||
685 | */ |
||
686 | public function setBapl($bapl = []) |
||
687 | { |
||
688 | $this->bapl = $bapl; |
||
689 | |||
690 | return $this; |
||
691 | } |
||
692 | |||
693 | /** |
||
694 | * @param Indi\Bapl $bapl |
||
695 | * |
||
696 | * @return Indi |
||
697 | */ |
||
698 | public function addBapl($bapl = null) |
||
703 | } |
||
704 | |||
705 | /** |
||
706 | * @return Indi\Bapl |
||
707 | */ |
||
708 | public function getBapl() |
||
709 | { |
||
710 | return $this->bapl; |
||
711 | } |
||
712 | |||
713 | /** |
||
714 | * @param Indi\Conl $conl |
||
715 | * |
||
716 | * @return Indi |
||
717 | */ |
||
718 | public function setConl($conl = []) |
||
719 | { |
||
720 | $this->conl = $conl; |
||
721 | |||
722 | return $this; |
||
723 | } |
||
724 | |||
725 | /** |
||
726 | * @param Indi\Conl $conl |
||
727 | * |
||
728 | * @return Indi |
||
729 | */ |
||
730 | public function addConl($conl) |
||
731 | { |
||
732 | $this->conl[] = $conl; |
||
733 | |||
734 | return $this; |
||
735 | } |
||
736 | |||
737 | /** |
||
738 | * @return Indi\Conl |
||
739 | */ |
||
740 | public function getConl() |
||
743 | } |
||
744 | |||
745 | /** |
||
746 | * @param Indi\Endl $endl |
||
747 | * |
||
748 | * @return Indi |
||
749 | */ |
||
750 | public function setEndl($endl = []) |
||
751 | { |
||
752 | $this->endl = $endl; |
||
753 | |||
754 | return $this; |
||
755 | } |
||
756 | |||
757 | /** |
||
758 | * @param Indi\Endl $endl |
||
759 | * |
||
760 | * @return Indi |
||
761 | */ |
||
762 | public function addEndl($endl) |
||
767 | } |
||
768 | |||
769 | /** |
||
770 | * @return Indi\Endl |
||
771 | */ |
||
772 | public function getEndl() |
||
773 | { |
||
774 | return $this->endl; |
||
775 | } |
||
776 | |||
777 | /** |
||
778 | * @param Indi\Slgc $slgc |
||
779 | * |
||
780 | * @return Indi |
||
781 | */ |
||
782 | public function setSlgc($slgc = []) |
||
787 | } |
||
788 | |||
789 | /** |
||
790 | * @param Indi\Slgc $slgc |
||
791 | * |
||
792 | * @return Indi |
||
793 | */ |
||
794 | public function addSlgc($slgc) |
||
795 | { |
||
796 | $this->slgc[] = $slgc; |
||
797 | |||
798 | return $this; |
||
799 | } |
||
800 | |||
801 | /** |
||
802 | * @return Indi\Slgc |
||
803 | */ |
||
804 | public function getSlgc() |
||
805 | { |
||
806 | return $this->slgc; |
||
807 | } |
||
808 | } |
||
809 |