Conditions | 23 |
Paths | 8193 |
Total Lines | 108 |
Code Lines | 59 |
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\Fam\Even &$even, $level) |
||
26 | { |
||
27 | $output = ''; |
||
28 | |||
29 | // $type; |
||
30 | $type = $even->getType(); |
||
31 | if (!empty($type)) { |
||
32 | $output .= $level.' '.$type."\n"; |
||
33 | } else { |
||
34 | return $output; |
||
35 | } |
||
36 | $level++; |
||
37 | |||
38 | // $type; |
||
39 | $type = $even->getType(); |
||
40 | if (!empty($type)) { |
||
41 | $output .= $level.' TYPE '.$type."\n"; |
||
42 | } |
||
43 | |||
44 | // $date; |
||
45 | $date = $even->getDate(); |
||
46 | if (!empty($date)) { |
||
47 | $output .= $level.' DATE '.$date."\n"; |
||
|
|||
48 | } |
||
49 | |||
50 | // Plac |
||
51 | $plac = $even->getPlac(); |
||
52 | if (!empty($plac)) { |
||
53 | $_convert = \PhpGedcom\Writer\Indi\Even\Plac::convert($plac, $level); |
||
54 | $output .= $_convert; |
||
55 | } |
||
56 | |||
57 | // $caus; |
||
58 | $caus = $even->getCaus(); |
||
59 | if (!empty($caus)) { |
||
60 | $output .= $level.' CAUS '.$caus."\n"; |
||
61 | } |
||
62 | |||
63 | // $age; |
||
64 | $age = $even->getAge(); |
||
65 | if (!empty($age)) { |
||
66 | $output .= $level.' AGE '.$age."\n"; |
||
67 | } |
||
68 | |||
69 | // $addr |
||
70 | $addr = $even->getAddr(); |
||
71 | if (!empty($addr)) { |
||
72 | $_convert = \PhpGedcom\Writer\Addr::convert($addr, $level); |
||
73 | $output .= $_convert; |
||
74 | } |
||
75 | |||
76 | // $phon = array() |
||
77 | $phon = $even->getPhon(); |
||
78 | if (!empty($phon) && count($phon) > 0) { |
||
79 | foreach ($phon as $item) { |
||
80 | $_convert = \PhpGedcom\Writer\Phon::convert($item, $level); |
||
81 | $output .= $_convert; |
||
82 | } |
||
83 | } |
||
84 | // $agnc |
||
85 | $agnc = $even->getAgnc(); |
||
86 | if (!empty($agnc)) { |
||
87 | $output .= $level.' AGNC '.$agnc."\n"; |
||
88 | } |
||
89 | |||
90 | // HUSB |
||
91 | $husb = $even->getHusb(); |
||
92 | if (!empty($husb)) { |
||
93 | $_convert = \PhpGedcom\Writer\Fam\Even\Husb::convert($husb, $level); |
||
94 | $output .= $_convert; |
||
95 | } |
||
96 | |||
97 | // WIFE |
||
98 | $wife = $even->getWife(); |
||
99 | if (!empty($wife)) { |
||
100 | $_convert = \PhpGedcom\Writer\Fam\Even\Wife::convert($wife, $level); |
||
101 | $output .= $_convert; |
||
102 | } |
||
103 | |||
104 | // $ref = array(); |
||
105 | // This is not in parser |
||
106 | |||
107 | // $obje = array(); |
||
108 | $obje = $even->getObje(); |
||
109 | if (!empty($obje) && count($obje) > 0) { |
||
110 | foreach ($obje as $item) { |
||
111 | $_convert = \PhpGedcom\Writer\ObjeRef::convert($item, $level); |
||
112 | $output .= $_convert; |
||
113 | } |
||
114 | } |
||
115 | // $sour = array(); |
||
116 | $sour = $even->getSour(); |
||
117 | if (!empty($sour) && count($sour) > 0) { |
||
118 | foreach ($sour as $item) { |
||
119 | $_convert = \PhpGedcom\Writer\SourRef::convert($item, $level); |
||
120 | $output .= $_convert; |
||
121 | } |
||
122 | } |
||
123 | // $note = array(); |
||
124 | $note = $even->getNote(); |
||
125 | if (!empty($note) && count($note) > 0) { |
||
126 | foreach ($note as $item) { |
||
127 | $_convert = \PhpGedcom\Writer\NoteRef::convert($item, $level); |
||
128 | $output .= $_convert; |
||
129 | } |
||
130 | } |
||
131 | |||
132 | return $output; |
||
133 | } |
||
135 |