| Conditions | 13 |
| Paths | 4096 |
| Total Lines | 101 |
| Code Lines | 45 |
| 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\Head &$head, $format = self::GEDCOM55) |
||
| 25 | { |
||
| 26 | $level = 0; |
||
| 27 | $output = $level." HEAD\n"; |
||
| 28 | |||
| 29 | // level up |
||
| 30 | $level++; |
||
| 31 | |||
| 32 | //SOUR |
||
| 33 | $sour = $head->getSour(); |
||
| 34 | if ($sour) { |
||
| 35 | $_convert = \Gedcom\Writer\Head\Sour::convert($sour, $level); |
||
| 36 | $output .= $_convert; |
||
| 37 | } |
||
| 38 | |||
| 39 | // DEST |
||
| 40 | $dest = $head->getDest(); |
||
| 41 | if ($dest) { |
||
| 42 | $output .= $level.' DEST '.$dest."\n"; |
||
| 43 | } |
||
| 44 | |||
| 45 | //Subm |
||
| 46 | $subm = $head->getSubm(); |
||
| 47 | if ($subm) { |
||
| 48 | $output .= $level.' SUBM '.$subm."\n"; |
||
| 49 | } |
||
| 50 | |||
| 51 | // SUBN |
||
| 52 | $subn = $head->getSubn(); |
||
| 53 | if ($subn) { |
||
| 54 | $output .= $level.' SUBN '.$subn."\n"; |
||
| 55 | } |
||
| 56 | |||
| 57 | // FILE |
||
| 58 | $file = $head->getFile(); |
||
| 59 | if ($file) { |
||
| 60 | $output .= $level.' FILE '.$file."\n"; |
||
| 61 | } |
||
| 62 | |||
| 63 | // COPR |
||
| 64 | $copr = $head->getCopr(); |
||
| 65 | if ($copr) { |
||
| 66 | $output .= $level.' COPR '.$copr."\n"; |
||
| 67 | } |
||
| 68 | |||
| 69 | // LANG |
||
| 70 | $lang = $head->getLang(); |
||
| 71 | if ($lang) { |
||
| 72 | $output .= $level.' LANG '.$lang."\n"; |
||
| 73 | } |
||
| 74 | // DATE |
||
| 75 | $date = $head->getDate(); |
||
| 76 | if ($date) { |
||
| 77 | $_convert = \Gedcom\Writer\Head\Date::convert($date, $level); |
||
| 78 | $output .= $_convert; |
||
| 79 | } |
||
| 80 | |||
| 81 | // GEDC |
||
| 82 | $gedc = $head->getGedc(); |
||
| 83 | if ($gedc) { |
||
| 84 | $_convert = \Gedcom\Writer\Head\Gedc::convert($gedc, $level); |
||
| 85 | $output .= $_convert; |
||
| 86 | } |
||
| 87 | |||
| 88 | // CHAR |
||
| 89 | $char = $head->getChar(); |
||
| 90 | if ($char) { |
||
| 91 | $_convert = \Gedcom\Writer\Head\Char::convert($char, $level); |
||
| 92 | $output .= $_convert; |
||
| 93 | } |
||
| 94 | // PLAC |
||
| 95 | $plac = $head->getPlac(); |
||
| 96 | if ($plac) { |
||
| 97 | $_convert = \Gedcom\Writer\Head\Plac::convert($plac, $level); |
||
| 98 | $output .= $_convert; |
||
| 99 | } |
||
| 100 | |||
| 101 | // NOTE |
||
| 102 | $note = $head->getNote(); |
||
| 103 | if ($note) { |
||
| 104 | $output .= $level.' NOTE '.$note."\n"; |
||
| 105 | } |
||
| 106 | // |
||
| 107 | /* |
||
| 108 | +1 SUBM @<XREF:SUBM>@ {1:1} |
||
| 109 | +1 SUBN @<XREF:SUBN>@ {0:1} |
||
| 110 | +1 FILE <FILE_NAME> {0:1} |
||
| 111 | +1 COPR <COPYRIGHT_GEDCOM_FILE> {0:1} |
||
| 112 | +1 GEDC {1:1} |
||
| 113 | +2 VERS <VERSION_NUMBER> {1:1} |
||
| 114 | +2 FORM <GEDCOM_FORM> {1:1} |
||
| 115 | +1 CHAR <CHARACTER_SET> {1:1} |
||
| 116 | +2 VERS <VERSION_NUMBER> {0:1} |
||
| 117 | +1 LANG <LANGUAGE_OF_TEXT> {0:1} |
||
| 118 | +1 PLAC {0:1} |
||
| 119 | +2 FORM <PLACE_HIERARCHY> {1:1} |
||
| 120 | +1 NOTE <GEDCOM_CONTENT_DESCRIPTION> {0:1} |
||
| 121 | +2 [CONT|CONC] <GEDCOM_CONTENT_DESCRIPTION> {0:M} |
||
| 122 | */ |
||
| 123 | |||
| 124 | return $output; |
||
| 125 | } |
||
| 127 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.