Code Duplication    Length = 35-35 lines in 2 locations

app/Functions/Functions.php 2 locations

@@ 341-375 (lines=35) @@
338
			if ($maxlength == 0 || count($node['path']) <= $maxlength) {
339
				$indi = $node['indi'];
340
				//-- check all parents and siblings of this node
341
				foreach ($indi->getChildFamilies(Auth::PRIV_HIDE) as $family) {
342
					$visited[$family->getXref()] = true;
343
					foreach ($family->getSpouses(Auth::PRIV_HIDE) as $spouse) {
344
						if (!isset($visited[$spouse->getXref()])) {
345
							$node1 = $node;
346
							$node1['length']++;
347
							$node1['path'][]      = $spouse;
348
							$node1['indi']        = $spouse;
349
							$node1['relations'][] = $parent_codes[$spouse->getSex()];
350
							$p1nodes[]            = $node1;
351
							if ($spouse === $person2) {
352
								$found   = true;
353
								$resnode = $node1;
354
							} else {
355
								$visited[$spouse->getXref()] = true;
356
							}
357
						}
358
					}
359
					foreach ($family->getChildren(Auth::PRIV_HIDE) as $child) {
360
						if (!isset($visited[$child->getXref()])) {
361
							$node1 = $node;
362
							$node1['length']++;
363
							$node1['path'][]      = $child;
364
							$node1['indi']        = $child;
365
							$node1['relations'][] = $sibling_codes[$child->getSex()];
366
							$p1nodes[]            = $node1;
367
							if ($child === $person2) {
368
								$found   = true;
369
								$resnode = $node1;
370
							} else {
371
								$visited[$child->getXref()] = true;
372
							}
373
						}
374
					}
375
				}
376
				//-- check all spouses and children of this node
377
				foreach ($indi->getSpouseFamilies(Auth::PRIV_HIDE) as $family) {
378
					$visited[$family->getXref()] = true;
@@ 377-411 (lines=35) @@
374
					}
375
				}
376
				//-- check all spouses and children of this node
377
				foreach ($indi->getSpouseFamilies(Auth::PRIV_HIDE) as $family) {
378
					$visited[$family->getXref()] = true;
379
					foreach ($family->getSpouses(Auth::PRIV_HIDE) as $spouse) {
380
						if (!in_array($spouse->getXref(), $node1) || !isset($visited[$spouse->getXref()])) {
381
							$node1 = $node;
382
							$node1['length']++;
383
							$node1['path'][]      = $spouse;
384
							$node1['indi']        = $spouse;
385
							$node1['relations'][] = $spouse_codes[$spouse->getSex()];
386
							$p1nodes[]            = $node1;
387
							if ($spouse === $person2) {
388
								$found   = true;
389
								$resnode = $node1;
390
							} else {
391
								$visited[$spouse->getXref()] = true;
392
							}
393
						}
394
					}
395
					foreach ($family->getChildren(Auth::PRIV_HIDE) as $child) {
396
						if (!isset($visited[$child->getXref()])) {
397
							$node1 = $node;
398
							$node1['length']++;
399
							$node1['path'][]      = $child;
400
							$node1['indi']        = $child;
401
							$node1['relations'][] = $child_codes[$child->getSex()];
402
							$p1nodes[]            = $node1;
403
							if ($child === $person2) {
404
								$found   = true;
405
								$resnode = $node1;
406
							} else {
407
								$visited[$child->getXref()] = true;
408
							}
409
						}
410
					}
411
				}
412
			}
413
			unset($p1nodes[$shortest]);
414
		}