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