| Conditions | 21 |
| Paths | 513 |
| Total Lines | 85 |
| Code Lines | 48 |
| 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\Subm &$subm) |
||
| 26 | { |
||
| 27 | $level = 0; |
||
| 28 | $output = ''; |
||
| 29 | $_subm = $subm->getSubn(); |
||
|
|
|||
| 30 | if (empty($_subm)) { |
||
| 31 | return $output; |
||
| 32 | } else { |
||
| 33 | $output .= $level.' '.$_subm.' SUBM '."\n"; |
||
| 34 | } |
||
| 35 | // level up |
||
| 36 | $level++; |
||
| 37 | |||
| 38 | // NAME |
||
| 39 | $name = $subm->getName(); |
||
| 40 | if (!empty($name)) { |
||
| 41 | $output .= $level.' NAME '.$name."\n"; |
||
| 42 | } |
||
| 43 | // $chan |
||
| 44 | $chan = $subm->getChan(); |
||
| 45 | if ($chan) { |
||
| 46 | $_convert = \PhpGedcom\Writer\Chan::convert($chan, $level); |
||
| 47 | $output .= $_convert; |
||
| 48 | } |
||
| 49 | |||
| 50 | // $addr |
||
| 51 | $addr = $subm->getAddr(); |
||
| 52 | if ($addr) { |
||
| 53 | $_convert = \PhpGedcom\Writer\Addr::convert($addr, $level); |
||
| 54 | $output .= $_convert; |
||
| 55 | } |
||
| 56 | |||
| 57 | // $rin |
||
| 58 | $rin = $subm->getRin(); |
||
| 59 | if (!empty($rin)) { |
||
| 60 | $output .= $level.' RIN '.$rin."\n"; |
||
| 61 | } |
||
| 62 | |||
| 63 | // $rfn |
||
| 64 | $rfn = $subm->getRfn(); |
||
| 65 | if (!empty($rfn)) { |
||
| 66 | $output .= $level.' RFN '.$rfn."\n"; |
||
| 67 | } |
||
| 68 | |||
| 69 | // $lang = array() |
||
| 70 | $langs = $subm->getLang(); |
||
| 71 | if (!empty($langs) && count($langs) > 0) { |
||
| 72 | foreach ($langs as $item) { |
||
| 73 | if ($item) { |
||
| 74 | $_convert = $level.' LANG '.$item."\n"; |
||
| 75 | $output .= $_convert; |
||
| 76 | } |
||
| 77 | } |
||
| 78 | } |
||
| 79 | |||
| 80 | // $phon = array() |
||
| 81 | $phon = $subm->getLang(); |
||
| 82 | if (!empty($phon) && count($phon) > 0) { |
||
| 83 | foreach ($phon as $item) { |
||
| 84 | if ($item) { |
||
| 85 | $_convert = \PhpGedcom\Writer\Phon::convert($item, $level); |
||
| 86 | $output .= $_convert; |
||
| 87 | } |
||
| 88 | } |
||
| 89 | } |
||
| 90 | |||
| 91 | // $obje = array() |
||
| 92 | $obje = $subm->getObje(); |
||
| 93 | if (!empty($obje) && count($obje) > 0) { |
||
| 94 | foreach ($obje as $item) { |
||
| 95 | $_convert = \PhpGedcom\Writer\ObjeRef::convert($item, $level); |
||
| 96 | $output .= $_convert; |
||
| 97 | } |
||
| 98 | } |
||
| 99 | |||
| 100 | // note |
||
| 101 | $note = $subm->getNote(); |
||
| 102 | if (!empty($note) && count($note) > 0) { |
||
| 103 | foreach ($note as $item) { |
||
| 104 | $_convert = \PhpGedcom\Writer\NoteRef::convert($item, $level); |
||
| 105 | $output .= $_convert; |
||
| 106 | } |
||
| 107 | } |
||
| 108 | |||
| 109 | return $output; |
||
| 110 | } |
||
| 112 |