| Conditions | 37 |
| Paths | 865 |
| Total Lines | 183 |
| Code Lines | 120 |
| 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 |
||
| 182 | public function printDescendency($person, $count, $showNav = true) { |
||
| 183 | global $lastGenSecondFam; |
||
| 184 | |||
| 185 | if ($count > $this->dgenerations) { |
||
| 186 | return 0; |
||
| 187 | } |
||
| 188 | $pid = $person->getXref(); |
||
| 189 | $tablealign = 'right'; |
||
| 190 | $otablealign = 'left'; |
||
| 191 | if (I18N::direction() === 'rtl') { |
||
| 192 | $tablealign = 'left'; |
||
| 193 | $otablealign = 'right'; |
||
| 194 | } |
||
| 195 | |||
| 196 | //-- put a space between families on the last generation |
||
| 197 | if ($count == $this->dgenerations - 1) { |
||
| 198 | if (isset($lastGenSecondFam)) { |
||
| 199 | echo '<br>'; |
||
| 200 | } |
||
| 201 | $lastGenSecondFam = true; |
||
| 202 | } |
||
| 203 | echo "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" id='table_$pid' class='hourglassChart' style='float:$tablealign'>"; |
||
| 204 | echo '<tr>'; |
||
| 205 | echo "<td style='text-align:$tablealign'>"; |
||
| 206 | $numkids = 0; |
||
| 207 | $families = $person->getSpouseFamilies(); |
||
| 208 | $famNum = 0; |
||
| 209 | $children = []; |
||
| 210 | if ($count < $this->dgenerations) { |
||
| 211 | // Put all of the children in a common array |
||
| 212 | foreach ($families as $family) { |
||
| 213 | $famNum++; |
||
| 214 | foreach ($family->getChildren() as $child) { |
||
| 215 | $children[] = $child; |
||
| 216 | } |
||
| 217 | } |
||
| 218 | |||
| 219 | $ct = count($children); |
||
| 220 | if ($ct > 0) { |
||
| 221 | echo "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" style='position: relative; top: auto; float: $tablealign;'>"; |
||
| 222 | for ($i = 0; $i < $ct; $i++) { |
||
| 223 | $person2 = $children[$i]; |
||
| 224 | $chil = $person2->getXref(); |
||
| 225 | echo '<tr>'; |
||
| 226 | echo '<td id="td_', $chil, '" class="', I18N::direction(), '" style="text-align:', $otablealign, '">'; |
||
| 227 | $kids = $this->printDescendency($person2, $count + 1, $showNav); |
||
| 228 | $numkids += $kids; |
||
| 229 | echo '</td>'; |
||
| 230 | |||
| 231 | // Print the lines |
||
| 232 | if ($ct > 1) { |
||
| 233 | if ($i == 0) { |
||
| 234 | // First child |
||
| 235 | echo "<td style='vertical-align:bottom'><img alt='' class='line1 tvertline' id='vline_$chil' src='" . Theme::theme()->parameter('image-vline') . "' width='3'></td>"; |
||
| 236 | } elseif ($i == $ct - 1) { |
||
| 237 | // Last child |
||
| 238 | echo "<td style='vertical-align:top'><img alt='' class='bvertline' id='vline_$chil' src='" . Theme::theme()->parameter('image-vline') . "' width='3'></td>"; |
||
| 239 | } else { |
||
| 240 | // Middle child |
||
| 241 | echo '<td style="background: url(\'' . Theme::theme()->parameter('image-vline') . '\');"><img src=\'' . Theme::theme()->parameter('image-spacer') . '\' width="3"></td>'; |
||
| 242 | } |
||
| 243 | } |
||
| 244 | echo '</tr>'; |
||
| 245 | } |
||
| 246 | echo '</table>'; |
||
| 247 | } |
||
| 248 | echo '</td>'; |
||
| 249 | echo '<td class="myCharts" width="', $this->getBoxDimensions()->width, '">'; |
||
| 250 | } |
||
| 251 | |||
| 252 | // Print the descendency expansion arrow |
||
| 253 | if ($count == $this->dgenerations) { |
||
| 254 | $numkids = 1; |
||
| 255 | $tbwidth = $this->getBoxDimensions()->width + 16; |
||
| 256 | for ($j = $count; $j < $this->dgenerations; $j++) { |
||
| 257 | echo "<div style='width: ", $tbwidth, "px;'><br></div></td><td style='width:", $this->getBoxDimensions()->width, "px'>"; |
||
| 258 | } |
||
| 259 | $kcount = 0; |
||
| 260 | foreach ($families as $family) { |
||
| 261 | $kcount += $family->getNumberOfChildren(); |
||
| 262 | } |
||
| 263 | if ($kcount == 0) { |
||
| 264 | echo "</td><td style='width:", $this->getBoxDimensions()->width, "px'>"; |
||
| 265 | } else { |
||
| 266 | echo FontAwesome::linkIcon('arrow-start', I18N::translate('Children'), [ |
||
| 267 | 'href' => '#', |
||
| 268 | 'data-direction' => 'desc', |
||
| 269 | 'data-xref' => $pid, |
||
| 270 | 'data-spouses' => $this->show_spouse, |
||
| 271 | ]); |
||
| 272 | |||
| 273 | //-- move the arrow up to line up with the correct box |
||
| 274 | if ($this->show_spouse) { |
||
| 275 | echo str_repeat('<br><br><br>', count($families)); |
||
| 276 | } |
||
| 277 | echo "</td><td style='width:", $this->getBoxDimensions()->width, "px'>"; |
||
| 278 | } |
||
| 279 | } |
||
| 280 | |||
| 281 | echo '<table cellspacing="0" cellpadding="0" border="0" id="table2_' . $pid . '"><tr><td> '; |
||
| 282 | FunctionsPrint::printPedigreePerson($person); |
||
| 283 | echo '</td><td> <img class="lineh1" src="' . Theme::theme()->parameter('image-hline') . '" width="7" height="3">'; |
||
| 284 | |||
| 285 | //----- Print the spouse |
||
| 286 | if ($this->show_spouse) { |
||
| 287 | foreach ($families as $family) { |
||
| 288 | echo "</td></tr><tr><td style='text-align:$otablealign'>"; |
||
| 289 | FunctionsPrint::printPedigreePerson($family->getSpouse($person)); |
||
| 290 | $numkids++; |
||
| 291 | echo '</td><td> </td>'; |
||
| 292 | } |
||
| 293 | //-- add offset divs to make things line up better |
||
| 294 | if ($count == $this->dgenerations) { |
||
| 295 | echo "<tr><td colspan '2'><div style='height:", ($this->bhalfheight / 2), 'px; width:', $this->getBoxDimensions()->width, "px;'><br></div>"; |
||
| 296 | } |
||
| 297 | } |
||
| 298 | echo '</td></tr></table>'; |
||
| 299 | |||
| 300 | // For the root person, print a down arrow that allows changing the root of tree |
||
| 301 | if ($showNav && $count == 1) { |
||
| 302 | if ($person->canShowName()) { |
||
| 303 | // -- print left arrow for decendants so that we can move down the tree |
||
| 304 | $famids = $person->getSpouseFamilies(); |
||
| 305 | //-- make sure there is more than 1 child in the family with parents |
||
| 306 | $cfamids = $person->getChildFamilies(); |
||
| 307 | $num = 0; |
||
| 308 | foreach ($cfamids as $family) { |
||
| 309 | $num += $family->getNumberOfChildren(); |
||
| 310 | } |
||
| 311 | if ($num > 0) { |
||
| 312 | echo '<div class="center" id="childarrow" style="position:absolute; width:', $this->getBoxDimensions()->width, 'px;">'; |
||
| 313 | echo FontAwesome::linkIcon('arrow-down', I18N::translate('Family'), ['href' => '#', 'id' => 'spouse-child-links']); |
||
| 314 | echo '<div id="childbox">'; |
||
| 315 | echo '<table cellspacing="0" cellpadding="0" border="0" class="person_box"><tr><td> '; |
||
| 316 | |||
| 317 | foreach ($famids as $family) { |
||
| 318 | echo "<span class='name1'>" . I18N::translate('Family') . '</span>'; |
||
| 319 | $spouse = $family->getSpouse($person); |
||
| 320 | if ($spouse) { |
||
| 321 | printf(self::SWITCH_LINK, $spouse->getXref(), $this->show_spouse, $this->generations, $spouse->getFullName()); |
||
| 322 | } |
||
| 323 | foreach ($family->getChildren() as $child) { |
||
| 324 | printf(self::SWITCH_LINK, $child->getXref(), $this->show_spouse, $this->generations, $child->getFullName()); |
||
| 325 | } |
||
| 326 | } |
||
| 327 | |||
| 328 | //-- print the siblings |
||
| 329 | foreach ($cfamids as $family) { |
||
| 330 | if ($family->getHusband() || $family->getWife()) { |
||
| 331 | echo "<span class='name1'>" . I18N::translate('Parents') . '</span>'; |
||
| 332 | $husb = $family->getHusband(); |
||
| 333 | if ($husb) { |
||
| 334 | printf(self::SWITCH_LINK, $husb->getXref(), $this->show_spouse, $this->generations, $husb->getFullName()); |
||
| 335 | } |
||
| 336 | $wife = $family->getWife(); |
||
| 337 | if ($wife) { |
||
| 338 | printf(self::SWITCH_LINK, $wife->getXref(), $this->show_spouse, $this->generations, $wife->getFullName()); |
||
| 339 | } |
||
| 340 | } |
||
| 341 | |||
| 342 | // filter out root person from children array so only siblings remain |
||
| 343 | $siblings = array_filter($family->getChildren(), function (Individual $item) use ($pid) { |
||
| 344 | return $item->getXref() != $pid; |
||
| 345 | }); |
||
| 346 | $num = count($siblings); |
||
| 347 | if ($num) { |
||
| 348 | echo "<span class='name1'>"; |
||
| 349 | echo $num > 1 ? I18N::translate('Siblings') : I18N::translate('Sibling'); |
||
| 350 | echo '</span>'; |
||
| 351 | foreach ($siblings as $child) { |
||
| 352 | printf(self::SWITCH_LINK, $child->getXref(), $this->show_spouse, $this->generations, $child->getFullName()); |
||
| 353 | } |
||
| 354 | } |
||
| 355 | } |
||
| 356 | echo '</td></tr></table>'; |
||
| 357 | echo '</div>'; |
||
| 358 | echo '</div>'; |
||
| 359 | } |
||
| 360 | } |
||
| 361 | } |
||
| 362 | echo '</td></tr></table>'; |
||
| 363 | |||
| 364 | return $numkids; |
||
| 365 | } |
||
| 447 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.