| 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 |
||
| 27 | public static function convert(\PhpGedcom\Record\Fam &$fam, $level=0) |
||
| 28 | { |
||
| 29 | |||
| 30 | $output = ""; |
||
| 31 | $id = $fam->getId(); |
||
|
|
|||
| 32 | if(empty($id)){ |
||
| 33 | return $output; |
||
| 34 | }else{ |
||
| 35 | $output.=$level." @".$id."@ FAM "."\n"; |
||
| 36 | } |
||
| 37 | // level up |
||
| 38 | $level++; |
||
| 39 | |||
| 40 | // HUSB |
||
| 41 | $husb = $fam->getHusb(); |
||
| 42 | if(!empty($husb)){ |
||
| 43 | $output.=$level." HUSB @".$husb."@\n"; |
||
| 44 | } |
||
| 45 | |||
| 46 | // WIFE |
||
| 47 | $wife = $fam->getWife(); |
||
| 48 | if(!empty($wife)){ |
||
| 49 | $output.=$level." WIFE @".$wife."@\n"; |
||
| 50 | } |
||
| 51 | |||
| 52 | // CHIL |
||
| 53 | $chil = $fam->getChil(); |
||
| 54 | if(!empty($chil) && count($chil) > 0){ |
||
| 55 | foreach($chil as $item){ |
||
| 56 | if($item){ |
||
| 57 | $_convert = $level." CHIL @".$item."@\n"; |
||
| 58 | $output.=$_convert; |
||
| 59 | } |
||
| 60 | } |
||
| 61 | } |
||
| 62 | // NCHI |
||
| 63 | $nchi = $fam->getNchi(); |
||
| 64 | if(!empty($nchi)){ |
||
| 65 | $output.=$level." NCHI ".$nchi."\n"; |
||
| 66 | } |
||
| 67 | |||
| 68 | // SUBM array |
||
| 69 | $subm = $fam->getSubm(); |
||
| 70 | |||
| 71 | if(!empty($subm) && count($subm) > 0){ |
||
| 72 | foreach($subm as $item){ |
||
| 73 | if($item){ |
||
| 74 | $output.=$level." SUBM ".$item."\n"; |
||
| 75 | } |
||
| 76 | } |
||
| 77 | } |
||
| 78 | |||
| 79 | // RIN |
||
| 80 | $rin = $fam->getRin(); |
||
| 81 | if(!empty($rin)){ |
||
| 82 | $output.=$level." RIN ".$rin."\n"; |
||
| 83 | } |
||
| 84 | // CHAN |
||
| 85 | $chan = $fam->getChan(); |
||
| 86 | if(!empty($chan)){ |
||
| 87 | $_convert = \PhpGedcom\Writer\Chan::convert($chan, $level); |
||
| 88 | $output.=$_convert; |
||
| 89 | } |
||
| 90 | // SLGS |
||
| 91 | $slgs = $fam->getSlgs(); |
||
| 92 | if(!empty($slgs) && count($slgs) > 0){ |
||
| 93 | if($slgs){ |
||
| 94 | $_convert = \PhpGedcom\Writer\Fam\Slgs::convert($item, $level); |
||
| 95 | $output.=$_convert; |
||
| 96 | } |
||
| 97 | } |
||
| 98 | |||
| 99 | // REFN array |
||
| 100 | $refn = $fam->getRefn(); |
||
| 101 | if(!empty($refn) && count($refn) > 0){ |
||
| 102 | foreach($refn as $item){ |
||
| 103 | if($item){ |
||
| 104 | $_convert = \PhpGedcom\Writer\Refn::convert($item, $level); |
||
| 105 | $output.=$_convert; |
||
| 106 | } |
||
| 107 | } |
||
| 108 | } |
||
| 109 | |||
| 110 | // NOTE array |
||
| 111 | $note = $fam->getNote(); |
||
| 112 | if(!empty($note) && count($note) > 0){ |
||
| 113 | foreach($note as $item){ |
||
| 114 | if($item){ |
||
| 115 | $_convert = \PhpGedcom\Writer\NoteRef::convert($item, $level); |
||
| 116 | $output.=$_convert; |
||
| 117 | } |
||
| 118 | } |
||
| 119 | } |
||
| 120 | |||
| 121 | // SOUR |
||
| 122 | $sour = $fam->getSour(); |
||
| 123 | if(!empty($sour) && count($sour) > 0){ |
||
| 124 | foreach($sour as $item){ |
||
| 125 | if($item){ |
||
| 126 | $_convert = \PhpGedcom\Writer\SourRef::convert($item, $level); |
||
| 127 | $output.=$_convert; |
||
| 128 | } |
||
| 129 | } |
||
| 130 | } |
||
| 131 | |||
| 132 | // OBJE |
||
| 133 | $obje = $fam->getObje(); |
||
| 134 | if(!empty($obje) && count($obje) > 0){ |
||
| 135 | foreach($obje as $item){ |
||
| 136 | if($item){ |
||
| 137 | $_convert = \PhpGedcom\Writer\ObjeRef::convert($item, $level); |
||
| 138 | $output.=$_convert; |
||
| 139 | } |
||
| 140 | } |
||
| 141 | } |
||
| 142 | |||
| 143 | // EVEN |
||
| 144 | $even = $fam->getAllEven(); |
||
| 145 | if(!empty($even) && count($even) > 0){ |
||
| 146 | foreach($even as $item){ |
||
| 147 | if($item){ |
||
| 148 | $_convert = \PhpGedcom\Writer\Fam\Even::convert($item, $level); |
||
| 149 | $output.=$_convert; |
||
| 150 | } |
||
| 151 | } |
||
| 152 | } |
||
| 153 | return $output; |
||
| 154 | } |
||
| 156 |