Conditions | 38 |
Paths | 12289 |
Total Lines | 127 |
Code Lines | 70 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
25 | public static function convert(\Gedcom\Record\Fam &$fam, $level = 0) |
||
26 | { |
||
27 | $output = ''; |
||
28 | $id = $fam->getId(); |
||
|
|||
29 | if (empty($id)) { |
||
30 | return $output; |
||
31 | } else { |
||
32 | $output .= $level.' @'.$id.'@ FAM '."\n"; |
||
33 | } |
||
34 | // level up |
||
35 | $level++; |
||
36 | |||
37 | // HUSB |
||
38 | $husb = $fam->getHusb(); |
||
39 | if (!empty($husb)) { |
||
40 | $output .= $level.' HUSB @'.$husb."@\n"; |
||
41 | } |
||
42 | |||
43 | // WIFE |
||
44 | $wife = $fam->getWife(); |
||
45 | if (!empty($wife)) { |
||
46 | $output .= $level.' WIFE @'.$wife."@\n"; |
||
47 | } |
||
48 | |||
49 | // CHIL |
||
50 | $chil = $fam->getChil(); |
||
51 | if (!empty($chil) && count($chil) > 0) { |
||
52 | foreach ($chil as $item) { |
||
53 | if ($item) { |
||
54 | $_convert = $level.' CHIL @'.$item."@\n"; |
||
55 | $output .= $_convert; |
||
56 | } |
||
57 | } |
||
58 | } |
||
59 | // NCHI |
||
60 | $nchi = $fam->getNchi(); |
||
61 | if (!empty($nchi)) { |
||
62 | $output .= $level.' NCHI '.$nchi."\n"; |
||
63 | } |
||
64 | |||
65 | // SUBM array |
||
66 | $subm = $fam->getSubm(); |
||
67 | |||
68 | if (!empty($subm) && count($subm) > 0) { |
||
69 | foreach ($subm as $item) { |
||
70 | if ($item) { |
||
71 | $output .= $level.' SUBM '.$item."\n"; |
||
72 | } |
||
73 | } |
||
74 | } |
||
75 | |||
76 | // RIN |
||
77 | $rin = $fam->getRin(); |
||
78 | if (!empty($rin)) { |
||
79 | $output .= $level.' RIN '.$rin."\n"; |
||
80 | } |
||
81 | // CHAN |
||
82 | $chan = $fam->getChan(); |
||
83 | if (!empty($chan)) { |
||
84 | $_convert = \Gedcom\Writer\Chan::convert($chan, $level); |
||
85 | $output .= $_convert; |
||
86 | } |
||
87 | // SLGS |
||
88 | $slgs = $fam->getSlgs(); |
||
89 | if (!empty($slgs) && count($slgs) > 0) { |
||
90 | if ($slgs) { |
||
91 | $_convert = \Gedcom\Writer\Fam\Slgs::convert($item, $level); |
||
92 | $output .= $_convert; |
||
93 | } |
||
94 | } |
||
95 | |||
96 | // REFN array |
||
97 | $refn = $fam->getRefn(); |
||
98 | if (!empty($refn) && count($refn) > 0) { |
||
99 | foreach ($refn as $item) { |
||
100 | if ($item) { |
||
101 | $_convert = \Gedcom\Writer\Refn::convert($item, $level); |
||
102 | $output .= $_convert; |
||
103 | } |
||
104 | } |
||
105 | } |
||
106 | |||
107 | // NOTE array |
||
108 | $note = $fam->getNote(); |
||
109 | if (!empty($note) && count($note) > 0) { |
||
110 | foreach ($note as $item) { |
||
111 | if ($item) { |
||
112 | $_convert = \Gedcom\Writer\NoteRef::convert($item, $level); |
||
113 | $output .= $_convert; |
||
114 | } |
||
115 | } |
||
116 | } |
||
117 | |||
118 | // SOUR |
||
119 | $sour = $fam->getSour(); |
||
120 | if (!empty($sour) && count($sour) > 0) { |
||
121 | foreach ($sour as $item) { |
||
122 | if ($item) { |
||
123 | $_convert = \Gedcom\Writer\SourRef::convert($item, $level); |
||
124 | $output .= $_convert; |
||
125 | } |
||
126 | } |
||
127 | } |
||
128 | |||
129 | // OBJE |
||
130 | $obje = $fam->getObje(); |
||
131 | if (!empty($obje) && count($obje) > 0) { |
||
132 | foreach ($obje as $item) { |
||
133 | if ($item) { |
||
134 | $_convert = \Gedcom\Writer\ObjeRef::convert($item, $level); |
||
135 | $output .= $_convert; |
||
136 | } |
||
137 | } |
||
138 | } |
||
139 | |||
140 | // EVEN |
||
141 | $even = $fam->getAllEven(); |
||
142 | if (!empty($even) && count($even) > 0) { |
||
143 | foreach ($even as $item) { |
||
144 | if ($item) { |
||
145 | $_convert = \Gedcom\Writer\Fam\Even::convert($item, $level); |
||
146 | $output .= $_convert; |
||
147 | } |
||
148 | } |
||
149 | } |
||
150 | |||
151 | return $output; |
||
152 | } |
||
154 |