| Conditions | 22 |
| Paths | 8192 |
| Total Lines | 99 |
| Code Lines | 55 |
| 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\Even &$even, $level = 0) |
||
| 28 | { |
||
| 29 | $output = ""; |
||
| 30 | |||
| 31 | // $_attr; |
||
| 32 | $attr = $even->getAttr(); |
||
|
|
|||
| 33 | if(!empty($attr)){ |
||
| 34 | $output.=$level." EVEN ".$attr."\n"; |
||
| 35 | }else{ |
||
| 36 | $output = $level." EVEN\n"; |
||
| 37 | } |
||
| 38 | $level++; |
||
| 39 | |||
| 40 | // $type; |
||
| 41 | $type = $even->getType(); |
||
| 42 | if(!empty($type)){ |
||
| 43 | $output.=$level." TYPE ".$type."\n"; |
||
| 44 | } |
||
| 45 | |||
| 46 | // $date; |
||
| 47 | $date = $even->getDate(); |
||
| 48 | if(!empty($date)){ |
||
| 49 | $output.=$level." DATE ".$date."\n"; |
||
| 50 | } |
||
| 51 | |||
| 52 | // Plac |
||
| 53 | $plac = $even->getPlac(); |
||
| 54 | if(!empty($plac)){ |
||
| 55 | $_convert = \PhpGedcom\Writer\Indi\Even\Plac::convert($plac, $level); |
||
| 56 | $output.=$_convert; |
||
| 57 | } |
||
| 58 | |||
| 59 | // $caus; |
||
| 60 | $caus = $even->getCaus(); |
||
| 61 | if(!empty($caus)){ |
||
| 62 | $output.=$level." CAUS ".$caus."\n"; |
||
| 63 | } |
||
| 64 | |||
| 65 | // $age; |
||
| 66 | $age = $even->getAge(); |
||
| 67 | if(!empty($age)){ |
||
| 68 | $output.=$level." AGE ".$age."\n"; |
||
| 69 | } |
||
| 70 | |||
| 71 | // $addr |
||
| 72 | $addr = $even->getAddr(); |
||
| 73 | if(!empty($addr)){ |
||
| 74 | $_convert = \PhpGedcom\Writer\Addr::convert($addr, $level); |
||
| 75 | $output.=$_convert; |
||
| 76 | } |
||
| 77 | |||
| 78 | // $phon = array() |
||
| 79 | $phon = $even->getPhon(); |
||
| 80 | if(!empty($phon) && count($phon) > 0){ |
||
| 81 | foreach($phon as $item){ |
||
| 82 | $_convert = \PhpGedcom\Writer\Phon::convert($item, $level); |
||
| 83 | $output.=$_convert; |
||
| 84 | } |
||
| 85 | } |
||
| 86 | // $agnc |
||
| 87 | $agnc = $even->getAgnc(); |
||
| 88 | if(!empty($agnc)){ |
||
| 89 | $output.=$level." AGNC ".$agnc."\n"; |
||
| 90 | } |
||
| 91 | |||
| 92 | // $ref = array(); |
||
| 93 | // This is not in parser |
||
| 94 | |||
| 95 | // $obje = array(); |
||
| 96 | $obje = $even->getObje(); |
||
| 97 | if(!empty($obje) && count($obje) > 0){ |
||
| 98 | foreach($obje as $item){ |
||
| 99 | $_convert = \PhpGedcom\Writer\ObjeRef::convert($item, $level); |
||
| 100 | $output.=$_convert; |
||
| 101 | } |
||
| 102 | } |
||
| 103 | // $sour = array(); |
||
| 104 | $sour = $even->getSour(); |
||
| 105 | if(!empty($sour) && count($sour) > 0){ |
||
| 106 | foreach($sour as $item){ |
||
| 107 | $_convert = \PhpGedcom\Writer\SourRef::convert($item, $level); |
||
| 108 | $output.=$_convert; |
||
| 109 | } |
||
| 110 | } |
||
| 111 | // $note = array(); |
||
| 112 | $note = $even->getSour(); |
||
| 113 | if(!empty($note) && count($note) > 0){ |
||
| 114 | foreach($note as $item){ |
||
| 115 | $_convert = \PhpGedcom\Writer\NoteRef::convert($item, $level); |
||
| 116 | $output.=$_convert; |
||
| 117 | } |
||
| 118 | } |
||
| 119 | // Record\Chan |
||
| 120 | $chan = $even->getChan(); |
||
| 121 | if(!empty($chan) ){ |
||
| 122 | $_convert = \PhpGedcom\Writer\Chan::convert($item, $level); |
||
| 123 | $output.=$_convert; |
||
| 124 | } |
||
| 125 | return $output; |
||
| 126 | } |
||
| 128 |