| Conditions | 51 |
| Paths | > 20000 |
| Total Lines | 219 |
| Code Lines | 95 |
| 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 |
||
| 27 | public static function convert(\PhpGedcom\Record\Indi &$indi) |
||
| 28 | { |
||
| 29 | $level = 0; |
||
| 30 | |||
| 31 | // id |
||
| 32 | $id = $indi->getId(); |
||
| 33 | $output = $level." @".$id."@ INDI\n"; |
||
| 34 | |||
| 35 | // increase level after start indi |
||
| 36 | $level++; |
||
| 37 | |||
| 38 | // name |
||
| 39 | // $name = $indi->getName(); |
||
| 40 | // if(!empty($name)){ |
||
| 41 | // $output.=$level." NAME ".$name."\n"; |
||
| 42 | // } |
||
| 43 | |||
| 44 | // chan |
||
| 45 | $chan = $indi->getChan(); |
||
| 46 | if(!empty($chan)){ |
||
| 47 | $output .= $level." CHAN ".$chan."\n"; |
||
| 48 | } |
||
| 49 | |||
| 50 | // $attr |
||
| 51 | // PhpGedcom/Record/Attr extend PhpGedcom/Record/Even and there is no change. |
||
| 52 | // So used convert Even |
||
| 53 | $attr = $indi->getAllAttr(); |
||
| 54 | if(!empty($attr) && count($attr) > 0){ |
||
| 55 | foreach($attr as $item){ |
||
| 56 | $_convert = \PhpGedcom\Writer\Indi\Even::convert($item, $level); |
||
| 57 | $output.=$_convert; |
||
| 58 | } |
||
| 59 | } |
||
| 60 | |||
| 61 | // $even |
||
| 62 | $even = $indi->getAllEven(); |
||
| 63 | if(!empty($even) && count($even) > 0){ |
||
| 64 | foreach($even as $item){ |
||
| 65 | $_convert = \PhpGedcom\Writer\Indi\Even::convert($item, $level); |
||
| 66 | $output.=$_convert; |
||
| 67 | } |
||
| 68 | } |
||
| 69 | |||
| 70 | // $note |
||
| 71 | |||
| 72 | $note = $indi->getNote(); |
||
| 73 | if(!empty($note) && count($note) > 0){ |
||
| 74 | foreach($note as $item){ |
||
| 75 | $_convert = \PhpGedcom\Writer\NoteRef::convert($item, $level); |
||
| 76 | $output.=$_convert; |
||
| 77 | } |
||
| 78 | } |
||
| 79 | |||
| 80 | // $obje |
||
| 81 | $obje = $indi->getObje(); |
||
| 82 | if(!empty($obje) && count($obje) > 0){ |
||
| 83 | foreach($obje as $item){ |
||
| 84 | $_convert = \PhpGedcom\Writer\ObjeRef::convert($item, $level); |
||
|
|
|||
| 85 | $output.=$_convert; |
||
| 86 | } |
||
| 87 | } |
||
| 88 | |||
| 89 | // $sour |
||
| 90 | $sour = $indi->getSour(); |
||
| 91 | if(!empty($sour) && count($sour) > 0){ |
||
| 92 | foreach($sour as $item){ |
||
| 93 | $_convert = \PhpGedcom\Writer\SourRef::convert($item, $level); |
||
| 94 | $output.=$_convert; |
||
| 95 | } |
||
| 96 | } |
||
| 97 | |||
| 98 | // $name |
||
| 99 | $name = $indi->getName(); |
||
| 100 | if(!empty($name) && count($name) > 0){ |
||
| 101 | foreach($name as $item){ |
||
| 102 | $_convert = \PhpGedcom\Writer\Indi\Name::convert($item, $level); |
||
| 103 | $output.=$_convert; |
||
| 104 | } |
||
| 105 | } |
||
| 106 | |||
| 107 | // $alia |
||
| 108 | $alia = $indi->getAlia(); |
||
| 109 | if(!empty($alia) && count($alia) > 0){ |
||
| 110 | foreach($alia as $item){ |
||
| 111 | if(!empty($item)){ |
||
| 112 | $_convert = $level." ALIA ".$item."\n"; |
||
| 113 | $output.=$_convert; |
||
| 114 | } |
||
| 115 | } |
||
| 116 | } |
||
| 117 | |||
| 118 | // $sex |
||
| 119 | $sex = $indi->getSex(); |
||
| 120 | if(!empty($sex)){ |
||
| 121 | $output .= $level." SEX ".$sex."\n"; |
||
| 122 | } |
||
| 123 | |||
| 124 | // $rin |
||
| 125 | $rin = $indi->getRin(); |
||
| 126 | if(!empty($rin)){ |
||
| 127 | $output .= $level." RIN ".$rin."\n"; |
||
| 128 | } |
||
| 129 | |||
| 130 | // $resn |
||
| 131 | $resn = $indi->getResn(); |
||
| 132 | if(!empty($resn)){ |
||
| 133 | $output .= $level." RESN ".$resn."\n"; |
||
| 134 | } |
||
| 135 | |||
| 136 | // $rfn |
||
| 137 | $rfn = $indi->getRfn(); |
||
| 138 | if(!empty($rfn)){ |
||
| 139 | $output .= $level." RFN ".$rfn."\n"; |
||
| 140 | } |
||
| 141 | |||
| 142 | // $afn |
||
| 143 | $afn = $indi->getAfn(); |
||
| 144 | if(!empty($afn)){ |
||
| 145 | $output .= $level." AFN ".$afn."\n"; |
||
| 146 | } |
||
| 147 | |||
| 148 | // Fams[] |
||
| 149 | $fams = $indi->getFams(); |
||
| 150 | if(!empty($fams) && count($fams) > 0){ |
||
| 151 | foreach($fams as $item){ |
||
| 152 | $_convert = \PhpGedcom\Writer\Indi\Fams::convert($item, $level); |
||
| 153 | $output.=$_convert; |
||
| 154 | } |
||
| 155 | } |
||
| 156 | |||
| 157 | // Famc[] |
||
| 158 | $famc = $indi->getFamc(); |
||
| 159 | if(!empty($famc) && count($famc) > 0){ |
||
| 160 | foreach($famc as $item){ |
||
| 161 | $_convert = \PhpGedcom\Writer\Indi\Famc::convert($item, $level); |
||
| 162 | $output.=$_convert; |
||
| 163 | } |
||
| 164 | } |
||
| 165 | |||
| 166 | // Asso[] |
||
| 167 | $asso = $indi->getAsso(); |
||
| 168 | if(!empty($asso) && count($asso) > 0){ |
||
| 169 | foreach($asso as $item){ |
||
| 170 | $_convert = \PhpGedcom\Writer\Indi\Asso::convert($item, $level); |
||
| 171 | $output.=$_convert; |
||
| 172 | } |
||
| 173 | } |
||
| 174 | |||
| 175 | // $subm |
||
| 176 | $subm = $indi->getSubm(); |
||
| 177 | if(!empty($subm) && count($subm) > 0){ |
||
| 178 | foreach($subm as $item){ |
||
| 179 | if(!empty($item)){ |
||
| 180 | $_convert = $level." SUBM ".$item."\n"; |
||
| 181 | $output.=$_convert; |
||
| 182 | } |
||
| 183 | } |
||
| 184 | } |
||
| 185 | |||
| 186 | // $anci |
||
| 187 | $anci = $indi->getAnci(); |
||
| 188 | if(!empty($anci) && count($anci) > 0){ |
||
| 189 | foreach($anci as $item){ |
||
| 190 | $_convert = $level." ANCI ".$item."\n"; |
||
| 191 | $output.=$_convert; |
||
| 192 | } |
||
| 193 | } |
||
| 194 | |||
| 195 | // $desi |
||
| 196 | $desi = $indi->getDesi(); |
||
| 197 | if(!empty($desi) && count($desi) > 0){ |
||
| 198 | foreach($desi as $item){ |
||
| 199 | $_convert = $level." DESI ".$item."\n"; |
||
| 200 | $output.=$_convert; |
||
| 201 | } |
||
| 202 | } |
||
| 203 | |||
| 204 | // Refn[] |
||
| 205 | $refn = $indi->getRefn(); |
||
| 206 | if(!empty($refn) && count($refn) > 0){ |
||
| 207 | foreach($refn as $item){ |
||
| 208 | $_convert = \PhpGedcom\Writer\Refn::convert($item, $level); |
||
| 209 | $output.=$_convert; |
||
| 210 | } |
||
| 211 | } |
||
| 212 | |||
| 213 | // Bapl |
||
| 214 | // Currently Bapl is empty |
||
| 215 | // $bapl = $indi->getBapl(); |
||
| 216 | // if(!empty($bapl)){ |
||
| 217 | // $_convert = \PhpGedcom\Writer\Indi\Bapl::convert($bapl, $level); |
||
| 218 | // $output.=$_convert; |
||
| 219 | // } |
||
| 220 | |||
| 221 | // Conl |
||
| 222 | // Currently Conl is empty |
||
| 223 | // $conl = $indi->getConl(); |
||
| 224 | // if(!empty($conl)){ |
||
| 225 | // $_convert = \PhpGedcom\Writer\Indi\Conl::convert($conl, $level); |
||
| 226 | // $output.=$_convert; |
||
| 227 | // } |
||
| 228 | |||
| 229 | // Endl |
||
| 230 | // Currently Endl is empty |
||
| 231 | // $endl = $indi->getEndl(); |
||
| 232 | // if(!empty($endl)){ |
||
| 233 | // $_convert = \PhpGedcom\Writer\Indi\Endl::convert($endl, $level); |
||
| 234 | // $output.=$_convert; |
||
| 235 | // } |
||
| 236 | |||
| 237 | // Slgc |
||
| 238 | // Currently Endl is empty |
||
| 239 | // $slgc = $indi->getSlgc(); |
||
| 240 | // if(!empty($slgc)){ |
||
| 241 | // $_convert = \PhpGedcom\Writer\Indi\Slgc::convert($slgc, $level); |
||
| 242 | // $output.=$_convert; |
||
| 243 | // } |
||
| 244 | |||
| 245 | return $output; |
||
| 246 | } |
||
| 248 |