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