Code Duplication    Length = 7-9 lines in 4 locations

app/Stats.php 4 locations

@@ 364-372 (lines=9) @@
361
	 *
362
	 * @return int
363
	 */
364
	private function totalIndisWithSourcesQuery() {
365
		return (int) Database::prepare(
366
			"SELECT SQL_CACHE COUNT(DISTINCT i_id)" .
367
			" FROM `##individuals` JOIN `##link` ON i_id = l_from AND i_file = l_file" .
368
			" WHERE l_file = :tree_id AND l_type = 'SOUR'"
369
		)->execute([
370
			'tree_id' => $this->tree->getTreeId(),
371
		])->fetchOne();
372
	}
373
374
	/**
375
	 * How many individuals have one or more sources.
@@ 462-470 (lines=9) @@
459
	 *
460
	 * @return int
461
	 */
462
	private function totalFamsWithSourcesQuery() {
463
		return (int) Database::prepare(
464
			"SELECT SQL_CACHE COUNT(DISTINCT f_id)" .
465
			" FROM `##families` JOIN `##link` ON f_id = l_from AND f_file = l_file" .
466
			" WHERE l_file = :tree_id AND l_type = 'SOUR'"
467
		)->execute([
468
			'tree_id' => $this->tree->getTreeId(),
469
		])->fetchOne();
470
	}
471
472
	/**
473
	 * Count the families with with source records.
@@ 970-976 (lines=7) @@
967
	 *
968
	 * @return int
969
	 */
970
	private function totalLivingQuery() {
971
		return (int) Database::prepare(
972
			"SELECT SQL_CACHE COUNT(*) FROM `##individuals` WHERE i_file = :tree_id AND i_gedcom NOT REGEXP '\\n1 (" . WT_EVENTS_DEAT . ")'"
973
		)->execute([
974
			'tree_id' => $this->tree->getTreeId(),
975
		])->fetchOne();
976
	}
977
978
	/**
979
	 * Count the number of living individuals.
@@ 1001-1007 (lines=7) @@
998
	 *
999
	 * @return int
1000
	 */
1001
	private function totalDeceasedQuery() {
1002
		return (int) Database::prepare(
1003
			"SELECT SQL_CACHE COUNT(*) FROM `##individuals` WHERE i_file = :tree_id AND i_gedcom REGEXP '\\n1 (" . WT_EVENTS_DEAT . ")'"
1004
		)->execute([
1005
			'tree_id' => $this->tree->getTreeId(),
1006
		])->fetchOne();
1007
	}
1008
1009
	/**
1010
	 * Count the number of dead individuals.