Code Duplication    Length = 17-19 lines in 2 locations

app/Stats.php 2 locations

@@ 2331-2349 (lines=19) @@
2328
			return '';
2329
		}
2330
		$top10 = [];
2331
		foreach ($rows as $row) {
2332
			$person = Individual::getInstance($row['deathdate'], $this->tree);
2333
			$age    = $row['age'];
2334
			if ((int) ($age / 365.25) > 0) {
2335
				$age = (int) ($age / 365.25) . 'y';
2336
			} elseif ((int) ($age / 30.4375) > 0) {
2337
				$age = (int) ($age / 30.4375) . 'm';
2338
			} else {
2339
				$age = $age . 'd';
2340
			}
2341
			$age = FunctionsDate::getAgeAtEvent($age);
2342
			if ($person->canShow()) {
2343
				if ($type == 'list') {
2344
					$top10[] = '<li><a href="' . $person->getHtmlUrl() . '">' . $person->getFullName() . '</a> (' . $age . ')' . '</li>';
2345
				} else {
2346
					$top10[] = '<a href="' . $person->getHtmlUrl() . '">' . $person->getFullName() . '</a> (' . $age . ')';
2347
				}
2348
			}
2349
		}
2350
		if ($type == 'list') {
2351
			$top10 = implode('', $top10);
2352
		} else {
@@ 2410-2426 (lines=17) @@
2407
			" ASC LIMIT " . $total
2408
		);
2409
		$top10 = [];
2410
		foreach ($rows as $row) {
2411
			$person = Individual::getInstance($row['id'], $this->tree);
2412
			$age    = (WT_CLIENT_JD - $row['age']);
2413
			if ((int) ($age / 365.25) > 0) {
2414
				$age = (int) ($age / 365.25) . 'y';
2415
			} elseif ((int) ($age / 30.4375) > 0) {
2416
				$age = (int) ($age / 30.4375) . 'm';
2417
			} else {
2418
				$age = $age . 'd';
2419
			}
2420
			$age = FunctionsDate::getAgeAtEvent($age);
2421
			if ($type === 'list') {
2422
				$top10[] = '<li><a href="' . $person->getHtmlUrl() . '">' . $person->getFullName() . '</a> (' . $age . ')' . '</li>';
2423
			} else {
2424
				$top10[] = '<a href="' . $person->getHtmlUrl() . '">' . $person->getFullName() . '</a> (' . $age . ')';
2425
			}
2426
		}
2427
		if ($type === 'list') {
2428
			$top10 = implode('', $top10);
2429
		} else {