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