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