Conditions | 24 |
Paths | 4719 |
Total Lines | 120 |
Code Lines | 82 |
Lines | 27 |
Ratio | 22.5 % |
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 |
||
185 | private function printPersonPedigree($person, $count) { |
||
186 | if ($count >= $this->generations) { |
||
187 | return; |
||
188 | } |
||
189 | |||
190 | $genoffset = $this->generations; // handle pedigree n generations lines |
||
191 | //-- calculate how tall the lines should be |
||
192 | $lh = ($this->bhalfheight) * pow(2, ($genoffset - $count - 1)); |
||
193 | // |
||
194 | //Prints empty table columns for children w/o parents up to the max generation |
||
195 | //This allows vertical line spacing to be consistent |
||
196 | if (count($person->getChildFamilies()) == 0) { |
||
197 | echo '<table cellspacing="0" cellpadding="0" border="0" >'; |
||
198 | $this->printEmptyBox(); |
||
199 | |||
200 | //-- recursively get the father’s family |
||
201 | $this->printPersonPedigree($person, $count + 1); |
||
202 | echo '</td><td></tr>'; |
||
203 | $this->printEmptyBox(); |
||
204 | |||
205 | //-- recursively get the mother’s family |
||
206 | $this->printPersonPedigree($person, $count + 1); |
||
207 | echo '</td><td></tr></table>'; |
||
208 | } |
||
209 | |||
210 | // Empty box section done, now for regular pedigree |
||
211 | foreach ($person->getChildFamilies() as $family) { |
||
212 | echo '<table cellspacing="0" cellpadding="0" border="0" ><tr><td class="align-bottom">'; |
||
213 | // Determine line height for two or more spouces |
||
214 | // And then adjust the vertical line for the root person only |
||
215 | $famcount = 0; |
||
216 | if ($this->show_spouse === '1') { |
||
217 | // count number of spouses |
||
218 | $famcount += count($person->getSpouseFamilies()); |
||
219 | } |
||
220 | $savlh = $lh; // Save current line height |
||
221 | if ($count == 1 && $genoffset <= $famcount) { |
||
222 | $linefactor = 0; |
||
223 | // genoffset of 2 needs no adjustment |
||
224 | if ($genoffset > 2) { |
||
225 | $tblheight = $this->getBoxDimensions()->height + 8; |
||
226 | if ($genoffset == 3) { |
||
227 | if ($famcount == 3) { |
||
228 | $linefactor = $tblheight / 2; |
||
229 | } elseif ($famcount > 3) { |
||
230 | $linefactor = $tblheight; |
||
231 | } |
||
232 | } |
||
233 | View Code Duplication | if ($genoffset == 4) { |
|
234 | if ($famcount == 4) { |
||
235 | $linefactor = $tblheight; |
||
236 | } elseif ($famcount > 4) { |
||
237 | $linefactor = ($famcount - $genoffset) * ($tblheight * 1.5); |
||
238 | } |
||
239 | } |
||
240 | View Code Duplication | if ($genoffset == 5) { |
|
241 | if ($famcount == 5) { |
||
242 | $linefactor = 0; |
||
243 | } elseif ($famcount > 5) { |
||
244 | $linefactor = $tblheight * ($famcount - $genoffset); |
||
245 | } |
||
246 | } |
||
247 | } |
||
248 | $lh = (($famcount - 1) * ($this->getBoxDimensions()->height) - ($linefactor)); |
||
249 | if ($genoffset > 5) { |
||
250 | $lh = $savlh; |
||
251 | } |
||
252 | } |
||
253 | echo '<img class="line3 pvline" src="', Theme::theme()->parameter('image-vline'), '" width="3" height="', $lh, '"></td>', |
||
254 | '<td>', |
||
255 | '<img class="linef2" src="', Theme::theme()->parameter('image-hline'), '" height="3"></td>', |
||
256 | '<td>'; |
||
257 | $lh = $savlh; // restore original line height |
||
258 | //-- print the father box |
||
259 | FunctionsPrint::printPedigreePerson($family->getHusband()); |
||
260 | echo '</td>'; |
||
261 | if ($family->getHusband()) { |
||
262 | echo '<td>'; |
||
263 | //-- recursively get the father’s family |
||
264 | $this->printPersonPedigree($family->getHusband(), $count + 1); |
||
265 | echo '</td>'; |
||
266 | } else { |
||
267 | echo '<td>'; |
||
268 | if ($genoffset > $count) { |
||
269 | echo '<table cellspacing="0" cellpadding="0" border="0" >'; |
||
270 | for ($i = 1; $i < (pow(2, ($genoffset) - $count) / 2); $i++) { |
||
271 | $this->printEmptyBox(); |
||
272 | echo '</tr>'; |
||
273 | } |
||
274 | echo '</table>'; |
||
275 | } |
||
276 | } |
||
277 | echo '</tr><tr>', |
||
278 | '<td class="align-top"><img class="pvline" src="', Theme::theme()->parameter('image-vline'), '" width="3" height="', $lh, '"></td>', |
||
279 | '<td><img class="linef3" src="', Theme::theme()->parameter('image-hline'), '" height="3"></td>', |
||
280 | '<td>'; |
||
281 | //-- print the mother box |
||
282 | FunctionsPrint::printPedigreePerson($family->getWife()); |
||
283 | echo '</td>'; |
||
284 | if ($family->getWife()) { |
||
285 | echo '<td>'; |
||
286 | //-- recursively print the mother’s family |
||
287 | $this->printPersonPedigree($family->getWife(), $count + 1); |
||
288 | echo '</td>'; |
||
289 | View Code Duplication | } else { |
|
290 | echo '<td>'; |
||
291 | if ($count < $genoffset - 1) { |
||
292 | echo '<table cellspacing="0" cellpadding="0" border="0" >'; |
||
293 | for ($i = 1; $i < (pow(2, ($genoffset - 1) - $count) / 2) + 1; $i++) { |
||
294 | $this->printEmptyBox(); |
||
295 | echo '</tr>'; |
||
296 | $this->printEmptyBox(); |
||
297 | echo '</tr>'; |
||
298 | } |
||
299 | echo '</table>'; |
||
300 | } |
||
301 | } |
||
302 | echo '</tr>', |
||
303 | '</table>'; |
||
304 | break; |
||
305 | } |
||
383 |