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