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