Conditions | 31 |
Paths | 512 |
Total Lines | 87 |
Code Lines | 44 |
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 |
||
43 | public static function convert(Gedcom $gedcom, $format = self::GEDCOM55) |
||
44 | { |
||
45 | $head = $gedcom->getHead(); |
||
46 | $subn = $gedcom->getSubn(); |
||
47 | $subms = $gedcom->getSubm(); // array() |
||
48 | $sours = $gedcom->getSour(); // array() |
||
49 | $indis = $gedcom->getIndi(); // array() |
||
50 | $fams = $gedcom->getFam(); // array() |
||
51 | $notes = $gedcom->getNote(); // array() |
||
52 | $repos = $gedcom->getRepo(); // array() |
||
53 | $objes = $gedcom->getObje(); // array() |
||
54 | |||
55 | $output = "0 FORMAT ".$format."\n"; |
||
56 | |||
57 | // head |
||
58 | if($head){ |
||
|
|||
59 | $output = Head::convert($head, $format); |
||
60 | } |
||
61 | |||
62 | // subn |
||
63 | if($subn){ |
||
64 | $output .= Subn::convert($subn); |
||
65 | } |
||
66 | |||
67 | // subms |
||
68 | if(!empty($subms) && count($subms) > 0){ |
||
69 | foreach($subms as $item){ |
||
70 | if($item){ |
||
71 | $output .= Subm::convert($item); |
||
72 | } |
||
73 | } |
||
74 | } |
||
75 | |||
76 | // sours |
||
77 | if(!empty($sours) && count($sours) > 0){ |
||
78 | foreach($sours as $item){ |
||
79 | if($item){ |
||
80 | $output .= Sour::convert($item); |
||
81 | } |
||
82 | } |
||
83 | } |
||
84 | |||
85 | // indis |
||
86 | if(!empty($indis) && count($indis) > 0){ |
||
87 | foreach($indis as $item){ |
||
88 | if($item){ |
||
89 | $output .= Indi::convert($item); |
||
90 | } |
||
91 | } |
||
92 | } |
||
93 | |||
94 | // fams |
||
95 | if(!empty($fams) && count($fams) > 0){ |
||
96 | foreach($fams as $item){ |
||
97 | if($item){ |
||
98 | $output .= Fam::convert($item); |
||
99 | } |
||
100 | } |
||
101 | } |
||
102 | // notes |
||
103 | if(!empty($notes) && count($notes) > 0){ |
||
104 | foreach($notes as $item){ |
||
105 | if($item){ |
||
106 | $output .= Note::convert($item); |
||
107 | } |
||
108 | } |
||
109 | } |
||
110 | |||
111 | // repos |
||
112 | if(!empty($repos) && count($repos) > 0){ |
||
113 | foreach($repos as $item){ |
||
114 | if($item){ |
||
115 | $output .= Repo::convert($item); |
||
116 | } |
||
117 | } |
||
118 | } |
||
119 | // Objes |
||
120 | if(!empty($objes) && count($objes) > 0){ |
||
121 | foreach($objes as $item){ |
||
122 | if($item){ |
||
123 | $output .= Obje::convert($item); |
||
124 | } |
||
125 | } |
||
126 | } |
||
127 | // EOF |
||
128 | $output .= "0 TRLR\n"; |
||
129 | return $output; |
||
130 | } |
||
132 |