| Conditions | 9 |
| Paths | 129 |
| Total Lines | 55 |
| Code Lines | 30 |
| 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(\Gedcom\Record\Subn &$subn) |
||
| 26 | { |
||
| 27 | $level = 0; |
||
| 28 | $output = ''; |
||
| 29 | $_subn = $subn->getSubn(); |
||
| 30 | if (empty($_subn)) { |
||
| 31 | return $output; |
||
| 32 | } else { |
||
| 33 | $output .= $level.' '.$_subn." SUBN \n"; |
||
| 34 | } |
||
| 35 | // level up |
||
| 36 | $level++; |
||
| 37 | |||
| 38 | // SUBM |
||
| 39 | $subm = $subn->getSubm(); |
||
| 40 | if (!empty($subm)) { |
||
| 41 | $output .= $level.' SUBM '.$subm."\n"; |
||
| 42 | } |
||
| 43 | |||
| 44 | // FAMF |
||
| 45 | $famf = $subn->getFamf(); |
||
| 46 | if (!empty($famf)) { |
||
| 47 | $output .= $level.' FAMF '.$famf."\n"; |
||
| 48 | } |
||
| 49 | |||
| 50 | // TEMP |
||
| 51 | $temp = $subn->getTemp(); |
||
| 52 | if (!empty($temp)) { |
||
| 53 | $output .= $level.' TEMP '.$temp."\n"; |
||
| 54 | } |
||
| 55 | |||
| 56 | // ANCE |
||
| 57 | $ance = $subn->getAnce(); |
||
| 58 | if (!empty($ance)) { |
||
| 59 | $output .= $level.' ANCE '.$ance."\n"; |
||
| 60 | } |
||
| 61 | |||
| 62 | // DESC |
||
| 63 | $desc = $subn->getDesc(); |
||
| 64 | if (!empty($desc)) { |
||
| 65 | $output .= $level.' DESC '.$desc."\n"; |
||
| 66 | } |
||
| 67 | // ORDI |
||
| 68 | $ordi = $subn->getOrdi(); |
||
| 69 | if (!empty($ordi)) { |
||
| 70 | $output .= $level.' ORDI '.$ordi."\n"; |
||
| 71 | } |
||
| 72 | |||
| 73 | // RIN |
||
| 74 | $rin = $subn->getRin(); |
||
| 75 | if (!empty($rin)) { |
||
| 76 | $output .= $level.' RIN '.$rin."\n"; |
||
| 77 | } |
||
| 78 | |||
| 79 | return $output; |
||
| 80 | } |
||
| 82 |