summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Roach <greg@subaqua.co.uk>2025-01-29 11:46:00 +0000
committerGreg Roach <greg@subaqua.co.uk>2025-01-29 13:33:56 +0000
commit408e1872937db088e11767d3e3874d0fa546ada4 (patch)
treea98eb6034eb995ea9576d5e7e77849f79600a211
parent65c7a260aa7150e5d699bf63b51839be0b5979b8 (diff)
downloadwebtrees-408e1872937db088e11767d3e3874d0fa546ada4.tar.gz
webtrees-408e1872937db088e11767d3e3874d0fa546ada4.tar.bz2
webtrees-408e1872937db088e11767d3e3874d0fa546ada4.zip
Refactor/simplify statistics
-rw-r--r--app/Statistics.php32
-rw-r--r--app/Statistics/Google/ChartAge.php9
-rw-r--r--app/Statistics/Google/ChartBirth.php13
-rw-r--r--app/Statistics/Google/ChartChildren.php9
-rw-r--r--app/Statistics/Google/ChartCommonGiven.php16
-rw-r--r--app/Statistics/Google/ChartCommonSurname.php17
-rw-r--r--app/Statistics/Google/ChartDeath.php13
-rw-r--r--app/Statistics/Google/ChartDistribution.php39
-rw-r--r--app/Statistics/Google/ChartDivorce.php7
-rw-r--r--app/Statistics/Google/ChartFamilyLargest.php41
-rw-r--r--app/Statistics/Google/ChartFamilyWithSources.php23
-rw-r--r--app/Statistics/Google/ChartIndividualWithSources.php23
-rw-r--r--app/Statistics/Google/ChartMarriage.php13
-rw-r--r--app/Statistics/Google/ChartMarriageAge.php9
-rw-r--r--app/Statistics/Google/ChartMedia.php11
-rw-r--r--app/Statistics/Google/ChartMortality.php23
-rw-r--r--app/Statistics/Google/ChartNoChildrenFamilies.php22
-rw-r--r--app/Statistics/Google/ChartSex.php26
-rw-r--r--app/Statistics/Repository/BrowserRepository.php6
-rw-r--r--app/Statistics/Repository/ContactRepository.php6
-rw-r--r--app/Statistics/Repository/EventRepository.php10
-rw-r--r--app/Statistics/Repository/FamilyDatesRepository.php14
-rw-r--r--app/Statistics/Repository/FamilyRepository.php481
-rw-r--r--app/Statistics/Repository/FavoritesRepository.php10
-rw-r--r--app/Statistics/Repository/GedcomRepository.php16
-rw-r--r--app/Statistics/Repository/HitCountRepository.php6
-rw-r--r--app/Statistics/Repository/IndividualRepository.php6
-rw-r--r--app/Statistics/Repository/Interfaces/BrowserRepositoryInterface.php29
-rw-r--r--app/Statistics/Repository/Interfaces/ContactRepositoryInterface.php27
-rw-r--r--app/Statistics/Repository/Interfaces/EventRepositoryInterface.php66
-rw-r--r--app/Statistics/Repository/Interfaces/FamilyDatesRepositoryInterface.php87
-rw-r--r--app/Statistics/Repository/Interfaces/FavoritesRepositoryInterface.php31
-rw-r--r--app/Statistics/Repository/Interfaces/GedcomRepositoryInterface.php39
-rw-r--r--app/Statistics/Repository/Interfaces/HitCountRepositoryInterface.php39
-rw-r--r--app/Statistics/Repository/Interfaces/IndividualRepositoryInterface.php73
-rw-r--r--app/Statistics/Repository/Interfaces/LatestUserRepositoryInterface.php35
-rw-r--r--app/Statistics/Repository/Interfaces/MediaRepositoryInterface.php65
-rw-r--r--app/Statistics/Repository/Interfaces/MessageRepositoryInterface.php25
-rw-r--r--app/Statistics/Repository/Interfaces/NewsRepositoryInterface.php27
-rw-r--r--app/Statistics/Repository/Interfaces/PlaceRepositoryInterface.php39
-rw-r--r--app/Statistics/Repository/Interfaces/ServerRepositoryInterface.php31
-rw-r--r--app/Statistics/Repository/Interfaces/UserRepositoryInterface.php45
-rw-r--r--app/Statistics/Repository/LatestUserRepository.php6
-rw-r--r--app/Statistics/Repository/MediaRepository.php6
-rw-r--r--app/Statistics/Repository/MessageRepository.php6
-rw-r--r--app/Statistics/Repository/NewsRepository.php6
-rw-r--r--app/Statistics/Repository/PlaceRepository.php8
-rw-r--r--app/Statistics/Repository/ServerRepository.php6
-rw-r--r--app/Statistics/Repository/UserRepository.php6
-rw-r--r--phpstan-baseline.neon48
50 files changed, 99 insertions, 1552 deletions
diff --git a/app/Statistics.php b/app/Statistics.php
index 4290471649..f2143aea6d 100644
--- a/app/Statistics.php
+++ b/app/Statistics.php
@@ -32,21 +32,6 @@ use Fisharebest\Webtrees\Statistics\Repository\FavoritesRepository;
use Fisharebest\Webtrees\Statistics\Repository\GedcomRepository;
use Fisharebest\Webtrees\Statistics\Repository\HitCountRepository;
use Fisharebest\Webtrees\Statistics\Repository\IndividualRepository;
-use Fisharebest\Webtrees\Statistics\Repository\Interfaces\BrowserRepositoryInterface;
-use Fisharebest\Webtrees\Statistics\Repository\Interfaces\ContactRepositoryInterface;
-use Fisharebest\Webtrees\Statistics\Repository\Interfaces\EventRepositoryInterface;
-use Fisharebest\Webtrees\Statistics\Repository\Interfaces\FamilyDatesRepositoryInterface;
-use Fisharebest\Webtrees\Statistics\Repository\Interfaces\FavoritesRepositoryInterface;
-use Fisharebest\Webtrees\Statistics\Repository\Interfaces\GedcomRepositoryInterface;
-use Fisharebest\Webtrees\Statistics\Repository\Interfaces\HitCountRepositoryInterface;
-use Fisharebest\Webtrees\Statistics\Repository\Interfaces\IndividualRepositoryInterface;
-use Fisharebest\Webtrees\Statistics\Repository\Interfaces\LatestUserRepositoryInterface;
-use Fisharebest\Webtrees\Statistics\Repository\Interfaces\MediaRepositoryInterface;
-use Fisharebest\Webtrees\Statistics\Repository\Interfaces\MessageRepositoryInterface;
-use Fisharebest\Webtrees\Statistics\Repository\Interfaces\NewsRepositoryInterface;
-use Fisharebest\Webtrees\Statistics\Repository\Interfaces\PlaceRepositoryInterface;
-use Fisharebest\Webtrees\Statistics\Repository\Interfaces\ServerRepositoryInterface;
-use Fisharebest\Webtrees\Statistics\Repository\Interfaces\UserRepositoryInterface;
use Fisharebest\Webtrees\Statistics\Repository\LatestUserRepository;
use Fisharebest\Webtrees\Statistics\Repository\MediaRepository;
use Fisharebest\Webtrees\Statistics\Repository\MessageRepository;
@@ -73,22 +58,7 @@ use function str_contains;
* These are primarily used for embedded keywords on HTML blocks, but
* are also used elsewhere in the code.
*/
-class Statistics implements
- GedcomRepositoryInterface,
- IndividualRepositoryInterface,
- EventRepositoryInterface,
- MediaRepositoryInterface,
- UserRepositoryInterface,
- ServerRepositoryInterface,
- BrowserRepositoryInterface,
- HitCountRepositoryInterface,
- LatestUserRepositoryInterface,
- FavoritesRepositoryInterface,
- NewsRepositoryInterface,
- MessageRepositoryInterface,
- ContactRepositoryInterface,
- FamilyDatesRepositoryInterface,
- PlaceRepositoryInterface
+class Statistics
{
private Tree $tree;
diff --git a/app/Statistics/Google/ChartAge.php b/app/Statistics/Google/ChartAge.php
index a16207ad71..c977e6f300 100644
--- a/app/Statistics/Google/ChartAge.php
+++ b/app/Statistics/Google/ChartAge.php
@@ -39,10 +39,6 @@ class ChartAge
private CenturyService $century_service;
- /**
- * @param CenturyService $century_service
- * @param Tree $tree
- */
public function __construct(CenturyService $century_service, Tree $tree)
{
$this->century_service = $century_service;
@@ -90,11 +86,6 @@ class ChartAge
]);
}
- /**
- * General query on ages.
- *
- * @return string
- */
public function chartAge(): string
{
$out = [];
diff --git a/app/Statistics/Google/ChartBirth.php b/app/Statistics/Google/ChartBirth.php
index 010ad3912e..50a3baf49b 100644
--- a/app/Statistics/Google/ChartBirth.php
+++ b/app/Statistics/Google/ChartBirth.php
@@ -40,11 +40,6 @@ class ChartBirth
private ColorService $color_service;
- /**
- * @param CenturyService $century_service
- * @param ColorService $color_service
- * @param Tree $tree
- */
public function __construct(CenturyService $century_service, ColorService $color_service, Tree $tree)
{
$this->century_service = $century_service;
@@ -75,14 +70,6 @@ class ChartBirth
]);
}
- /**
- * Create a chart of birth places.
- *
- * @param string|null $color_from
- * @param string|null $color_to
- *
- * @return string
- */
public function chartBirth(string|null $color_from = null, string|null $color_to = null): string
{
$color_from ??= 'ffffff';
diff --git a/app/Statistics/Google/ChartChildren.php b/app/Statistics/Google/ChartChildren.php
index d99cfa53fc..0ec3d2417a 100644
--- a/app/Statistics/Google/ChartChildren.php
+++ b/app/Statistics/Google/ChartChildren.php
@@ -35,10 +35,6 @@ class ChartChildren
private CenturyService $century_service;
- /**
- * @param CenturyService $century_service
- * @param Tree $tree
- */
public function __construct(CenturyService $century_service, Tree $tree)
{
$this->century_service = $century_service;
@@ -72,11 +68,6 @@ class ChartChildren
]);
}
- /**
- * Creates a children per family chart.
- *
- * @return string
- */
public function chartChildren(): string
{
$data = [
diff --git a/app/Statistics/Google/ChartCommonGiven.php b/app/Statistics/Google/ChartCommonGiven.php
index 245853fdc4..862bcb33c6 100644
--- a/app/Statistics/Google/ChartCommonGiven.php
+++ b/app/Statistics/Google/ChartCommonGiven.php
@@ -32,26 +32,16 @@ class ChartCommonGiven
{
private ColorService $color_service;
- /**
- * @param ColorService $color_service
- */
public function __construct(ColorService $color_service)
{
$this->color_service = $color_service;
}
/**
- * Create a chart of common given names.
- *
- * @param int $tot_indi The total number of individuals
- * @param array<int> $given The list of common given names
- * @param string|null $color_from
- * @param string|null $color_to
- *
- * @return string
+ * @param array<int> $given
*/
public function chartCommonGiven(
- int $tot_indi,
+ int $total_individuals,
array $given,
string|null $color_from = null,
string|null $color_to = null
@@ -77,7 +67,7 @@ class ChartCommonGiven
$data[] = [
I18N::translate('Other'),
- $tot_indi - $tot
+ $total_individuals - $tot
];
$colors = $this->color_service->interpolateRgb($color_from, $color_to, count($data) - 1);
diff --git a/app/Statistics/Google/ChartCommonSurname.php b/app/Statistics/Google/ChartCommonSurname.php
index be75bec6a3..c91e5f4a2c 100644
--- a/app/Statistics/Google/ChartCommonSurname.php
+++ b/app/Statistics/Google/ChartCommonSurname.php
@@ -38,10 +38,6 @@ class ChartCommonSurname
private SurnameTraditionInterface $surname_tradition;
- /**
- * @param ColorService $color_service
- * @param SurnameTraditionInterface $surname_tradition
- */
public function __construct(ColorService $color_service, SurnameTraditionInterface $surname_tradition)
{
$this->surname_tradition = $surname_tradition;
@@ -99,17 +95,10 @@ class ChartCommonSurname
}
/**
- * Create a chart of common surnames.
- *
- * @param int $tot_indi The total number of individuals
- * @param array<array<int>> $all_surnames The list of common surnames
- * @param string|null $color_from
- * @param string|null $color_to
- *
- * @return string
+ * @param array<array<int>> $all_surnames
*/
public function chartCommonSurnames(
- int $tot_indi,
+ int $total_individuals,
array $all_surnames,
string|null $color_from = null,
string|null $color_to = null
@@ -135,7 +124,7 @@ class ChartCommonSurname
$data[] = [
I18N::translate('Other'),
- $tot_indi - $tot
+ $total_individuals - $tot
];
$colors = $this->color_service->interpolateRgb($color_from, $color_to, count($data) - 1);
diff --git a/app/Statistics/Google/ChartDeath.php b/app/Statistics/Google/ChartDeath.php
index 7db089b12a..8c949d3112 100644
--- a/app/Statistics/Google/ChartDeath.php
+++ b/app/Statistics/Google/ChartDeath.php
@@ -40,11 +40,6 @@ class ChartDeath
private ColorService $color_service;
- /**
- * @param CenturyService $century_service
- * @param ColorService $color_service
- * @param Tree $tree
- */
public function __construct(CenturyService $century_service, ColorService $color_service, Tree $tree)
{
$this->century_service = $century_service;
@@ -75,14 +70,6 @@ class ChartDeath
]);
}
- /**
- * Create a chart of death places.
- *
- * @param string|null $color_from
- * @param string|null $color_to
- *
- * @return string
- */
public function chartDeath(string|null $color_from = null, string|null $color_to = null): string
{
$color_from ??= 'ffffff';
diff --git a/app/Statistics/Google/ChartDistribution.php b/app/Statistics/Google/ChartDistribution.php
index 2d591f5c33..395065b7cf 100644
--- a/app/Statistics/Google/ChartDistribution.php
+++ b/app/Statistics/Google/ChartDistribution.php
@@ -21,7 +21,7 @@ namespace Fisharebest\Webtrees\Statistics\Google;
use Fisharebest\Webtrees\DB;
use Fisharebest\Webtrees\I18N;
-use Fisharebest\Webtrees\Statistics\Repository\Interfaces\IndividualRepositoryInterface;
+use Fisharebest\Webtrees\Statistics\Repository\IndividualRepository;
use Fisharebest\Webtrees\Statistics\Service\CountryService;
use Fisharebest\Webtrees\Tree;
use Illuminate\Database\Query\Builder;
@@ -41,22 +41,17 @@ class ChartDistribution
private CountryService $country_service;
- private IndividualRepositoryInterface $individual_repository;
+ private IndividualRepository $individual_repository;
/**
* @var array<string>
*/
private array $country_to_iso3166;
- /**
- * @param Tree $tree
- * @param CountryService $country_service
- * @param IndividualRepositoryInterface $individual_repository
- */
public function __construct(
Tree $tree,
CountryService $country_service,
- IndividualRepositoryInterface $individual_repository
+ IndividualRepository $individual_repository
) {
$this->tree = $tree;
$this->country_service = $country_service;
@@ -67,8 +62,6 @@ class ChartDistribution
}
/**
- * Returns the country names for each language.
- *
* @return array<string>
*/
private function getIso3166Countries(): array
@@ -125,9 +118,7 @@ class ChartDistribution
}
/**
- * @param Tree $tree
- *
- * @return array<int>
+ * @return array<string,int>
*/
private function countIndividualsByCountry(Tree $tree): array
{
@@ -161,10 +152,7 @@ class ChartDistribution
}
/**
- * @param Tree $tree
- * @param string $surname
- *
- * @return array<int>
+ * @return array<string,int>
*/
private function countSurnamesByCountry(Tree $tree, string $surname): array
{
@@ -200,10 +188,7 @@ class ChartDistribution
}
/**
- * @param Tree $tree
- * @param string $fact
- *
- * @return array<int>
+ * @return array<string,int>
*/
private function countFamilyEventsByCountry(Tree $tree, string $fact): array
{
@@ -226,10 +211,7 @@ class ChartDistribution
}
/**
- * @param Tree $tree
- * @param string $fact
- *
- * @return array<int>
+ * @return array<string,int>
*/
private function countIndividualEventsByCountry(Tree $tree, string $fact): array
{
@@ -252,10 +234,7 @@ class ChartDistribution
}
/**
- * @param Builder $query
- * @param string $fact
- *
- * @return array<int>
+ * @return array<string,int>
*/
private function filterEventPlaces(Builder $query, string $fact): array
{
@@ -282,8 +261,6 @@ class ChartDistribution
* @param string $chart_shows The type of chart map to show
* @param string $chart_type The type of chart to show
* @param string $surname The surname for surname based distribution chart
- *
- * @return string
*/
public function chartDistribution(
string $chart_shows = 'world',
diff --git a/app/Statistics/Google/ChartDivorce.php b/app/Statistics/Google/ChartDivorce.php
index 77e4ffac14..7c6a1c3776 100644
--- a/app/Statistics/Google/ChartDivorce.php
+++ b/app/Statistics/Google/ChartDivorce.php
@@ -40,11 +40,6 @@ class ChartDivorce
private ColorService $color_service;
- /**
- * @param CenturyService $century_service
- * @param ColorService $color_service
- * @param Tree $tree
- */
public function __construct(CenturyService $century_service, ColorService $color_service, Tree $tree)
{
$this->century_service = $century_service;
@@ -80,8 +75,6 @@ class ChartDivorce
*
* @param string|null $color_from
* @param string|null $color_to
- *
- * @return string
*/
public function chartDivorce(string|null $color_from = null, string|null $color_to = null): string
{
diff --git a/app/Statistics/Google/ChartFamilyLargest.php b/app/Statistics/Google/ChartFamilyLargest.php
index b87850041c..0beba905b3 100644
--- a/app/Statistics/Google/ChartFamilyLargest.php
+++ b/app/Statistics/Google/ChartFamilyLargest.php
@@ -40,43 +40,12 @@ class ChartFamilyLargest
private ColorService $color_service;
- /**
- * @param ColorService $color_service
- * @param Tree $tree
- */
public function __construct(ColorService $color_service, Tree $tree)
{
$this->tree = $tree;
$this->color_service = $color_service;
}
- /**
- * Returns the related database records.
- *
- * @param int $total
- *
- * @return array<object>
- */
- private function queryRecords(int $total): array
- {
- $query = DB::table('families')
- ->select(['f_numchil AS total', 'f_id AS id'])
- ->where('f_file', '=', $this->tree->id())
- ->orderBy('total', 'desc')
- ->limit($total);
-
- return $query->get()->all();
- }
-
- /**
- * Create a chart of the largest families.
- *
- * @param string|null $color_from
- * @param string|null $color_to
- * @param int $total
- *
- * @return string
- */
public function chartLargestFamilies(
string|null $color_from = null,
string|null $color_to = null,
@@ -92,7 +61,15 @@ class ChartFamilyLargest
],
];
- foreach ($this->queryRecords($total) as $record) {
+ $records = DB::table('families')
+ ->select(['f_numchil AS total', 'f_id AS id'])
+ ->where('f_file', '=', $this->tree->id())
+ ->orderBy('total', 'desc')
+ ->limit($total)
+ ->get()
+ ->all();
+
+ foreach ($records as $record) {
$family = Registry::familyFactory()->make($record->id, $this->tree);
if ($family instanceof Family && $family->canShow()) {
diff --git a/app/Statistics/Google/ChartFamilyWithSources.php b/app/Statistics/Google/ChartFamilyWithSources.php
index 74713c9ad3..b1cf7bdd0d 100644
--- a/app/Statistics/Google/ChartFamilyWithSources.php
+++ b/app/Statistics/Google/ChartFamilyWithSources.php
@@ -32,27 +32,14 @@ class ChartFamilyWithSources
{
private ColorService $color_service;
- /**
- * @param ColorService $color_service
- */
public function __construct(ColorService $color_service)
{
$this->color_service = $color_service;
}
- /**
- * Create a chart of individuals with/without sources.
- *
- * @param int $tot_fam The total number of families
- * @param int $tot_fam_source The total number of families with sources
- * @param string|null $color_from
- * @param string|null $color_to
- *
- * @return string
- */
public function chartFamsWithSources(
- int $tot_fam,
- int $tot_fam_source,
+ int $total_families,
+ int $total_families_with_sources,
string|null $color_from = null,
string|null $color_to = null
): string {
@@ -66,15 +53,15 @@ class ChartFamilyWithSources
],
];
- if ($tot_fam > 0 || $tot_fam_source > 0) {
+ if ($total_families > 0 || $total_families_with_sources > 0) {
$data[] = [
I18N::translate('Without sources'),
- $tot_fam - $tot_fam_source
+ $total_families - $total_families_with_sources
];
$data[] = [
I18N::translate('With sources'),
- $tot_fam_source
+ $total_families_with_sources
];
}
diff --git a/app/Statistics/Google/ChartIndividualWithSources.php b/app/Statistics/Google/ChartIndividualWithSources.php
index 87fb4ed702..08e96d67b0 100644
--- a/app/Statistics/Google/ChartIndividualWithSources.php
+++ b/app/Statistics/Google/ChartIndividualWithSources.php
@@ -32,27 +32,14 @@ class ChartIndividualWithSources
{
private ColorService $color_service;
- /**
- * @param ColorService $color_service
- */
public function __construct(ColorService $color_service)
{
$this->color_service = $color_service;
}
- /**
- * Create a chart showing individuals with/without sources.
- *
- * @param int $tot_indi The total number of individuals
- * @param int $tot_indi_source The total number of individuals with sources
- * @param string|null $color_from
- * @param string|null $color_to
- *
- * @return string
- */
public function chartIndisWithSources(
- int $tot_indi,
- int $tot_indi_source,
+ int $total_individuals,
+ int $total_individuals_with_sources,
string|null $color_from = null,
string|null $color_to = null
): string {
@@ -66,15 +53,15 @@ class ChartIndividualWithSources
],
];
- if ($tot_indi > 0 || $tot_indi_source > 0) {
+ if ($total_individuals > 0 || $total_individuals_with_sources > 0) {
$data[] = [
I18N::translate('Without sources'),
- $tot_indi - $tot_indi_source
+ $total_individuals - $total_individuals_with_sources
];
$data[] = [
I18N::translate('With sources'),
- $tot_indi_source
+ $total_individuals_with_sources
];
}
diff --git a/app/Statistics/Google/ChartMarriage.php b/app/Statistics/Google/ChartMarriage.php
index 165d424582..c66cac76b0 100644
--- a/app/Statistics/Google/ChartMarriage.php
+++ b/app/Statistics/Google/ChartMarriage.php
@@ -40,11 +40,6 @@ class ChartMarriage
private ColorService $color_service;
- /**
- * @param CenturyService $century_service
- * @param ColorService $color_service
- * @param Tree $tree
- */
public function __construct(CenturyService $century_service, ColorService $color_service, Tree $tree)
{
$this->tree = $tree;
@@ -75,14 +70,6 @@ class ChartMarriage
]);
}
- /**
- * General query on marriages.
- *
- * @param string|null $color_from
- * @param string|null $color_to
- *
- * @return string
- */
public function chartMarriage(string|null $color_from = null, string|null $color_to = null): string
{
$color_from ??= 'ffffff';
diff --git a/app/Statistics/Google/ChartMarriageAge.php b/app/Statistics/Google/ChartMarriageAge.php
index 5b877c13b9..89805669f4 100644
--- a/app/Statistics/Google/ChartMarriageAge.php
+++ b/app/Statistics/Google/ChartMarriageAge.php
@@ -39,10 +39,6 @@ class ChartMarriageAge
private CenturyService $century_service;
- /**
- * @param CenturyService $century_service
- * @param Tree $tree
- */
public function __construct(CenturyService $century_service, Tree $tree)
{
$this->tree = $tree;
@@ -112,11 +108,6 @@ class ChartMarriageAge
]);
}
- /**
- * General query on ages at marriage.
- *
- * @return string
- */
public function chartMarriageAge(): string
{
$out = [];
diff --git a/app/Statistics/Google/ChartMedia.php b/app/Statistics/Google/ChartMedia.php
index 389e19ca1b..bbdf82d196 100644
--- a/app/Statistics/Google/ChartMedia.php
+++ b/app/Statistics/Google/ChartMedia.php
@@ -33,22 +33,13 @@ class ChartMedia
{
private ColorService $color_service;
- /**
- * @param ColorService $color_service
- */
public function __construct(ColorService $color_service)
{
$this->color_service = $color_service;
}
/**
- * Create a chart of media types.
- *
- * @param array<string,int> $media The list of media types to display
- * @param string|null $color_from
- * @param string|null $color_to
- *
- * @return string
+ * @param array<string,int> $media
*/
public function chartMedia(
array $media,
diff --git a/app/Statistics/Google/ChartMortality.php b/app/Statistics/Google/ChartMortality.php
index 7d95e32dfb..6066a8b307 100644
--- a/app/Statistics/Google/ChartMortality.php
+++ b/app/Statistics/Google/ChartMortality.php
@@ -32,27 +32,14 @@ class ChartMortality
{
private ColorService $color_service;
- /**
- * @param ColorService $color_service
- */
public function __construct(ColorService $color_service)
{
$this->color_service = $color_service;
}
- /**
- * Create a chart showing mortality.
- *
- * @param int $tot_l
- * @param int $tot_d
- * @param string|null $color_living
- * @param string|null $color_dead
- *
- * @return string
- */
public function chartMortality(
- int $tot_l,
- int $tot_d,
+ int $tot_living,
+ int $tot_dead,
string|null $color_living = null,
string|null $color_dead = null
): string {
@@ -66,15 +53,15 @@ class ChartMortality
]
];
- if ($tot_l > 0 || $tot_d > 0) {
+ if ($tot_living > 0 || $tot_dead > 0) {
$data[] = [
I18N::translate('Living'),
- $tot_l
+ $tot_living
];
$data[] = [
I18N::translate('Dead'),
- $tot_d
+ $tot_dead
];
}
diff --git a/app/Statistics/Google/ChartNoChildrenFamilies.php b/app/Statistics/Google/ChartNoChildrenFamilies.php
index 6a389e80ef..a4cfbeafea 100644
--- a/app/Statistics/Google/ChartNoChildrenFamilies.php
+++ b/app/Statistics/Google/ChartNoChildrenFamilies.php
@@ -36,10 +36,6 @@ class ChartNoChildrenFamilies
private CenturyService $century_service;
- /**
- * @param CenturyService $century_service
- * @param Tree $tree
- */
public function __construct(CenturyService $century_service, Tree $tree)
{
$this->century_service = $century_service;
@@ -47,11 +43,6 @@ class ChartNoChildrenFamilies
}
/**
- * Returns the related database records.
- *
- * @param int $year1
- * @param int $year2
- *
* @return array<object>
*/
private function queryRecords(int $year1, int $year2): array
@@ -77,17 +68,8 @@ class ChartNoChildrenFamilies
return $query->get()->all();
}
- /**
- * Create a chart of children with no families.
- *
- * @param int $no_child_fam The number of families with no children
- * @param int $year1
- * @param int $year2
- *
- * @return string
- */
public function chartNoChildrenFamilies(
- int $no_child_fam,
+ int $families_with_no_children,
int $year1 = -1,
int $year2 = -1
): string {
@@ -112,7 +94,7 @@ class ChartNoChildrenFamilies
if ($total > 0) {
$data[] = [
I18N::translateContext('unknown century', 'Unknown'),
- $no_child_fam - $total,
+ $families_with_no_children - $total,
];
}
diff --git a/app/Statistics/Google/ChartSex.php b/app/Statistics/Google/ChartSex.php
index 9cfbbeb955..36766b0f9b 100644
--- a/app/Statistics/Google/ChartSex.php
+++ b/app/Statistics/Google/ChartSex.php
@@ -26,22 +26,10 @@ use Fisharebest\Webtrees\I18N;
*/
class ChartSex
{
- /**
- * Generate a chart showing sex distribution.
- *
- * @param int $tot_m The total number of male individuals
- * @param int $tot_f The total number of female individuals
- * @param int $tot_u The total number of unknown individuals
- * @param string|null $color_female
- * @param string|null $color_male
- * @param string|null $color_unknown
- *
- * @return string
- */
public function chartSex(
- int $tot_m,
- int $tot_f,
- int $tot_u,
+ int $total_male,
+ int $total_female,
+ int $total_unknown,
string|null $color_female = null,
string|null $color_male = null,
string|null $color_unknown = null
@@ -57,20 +45,20 @@ class ChartSex
],
];
- if ($tot_m > 0 || $tot_f > 0 || $tot_u > 0) {
+ if ($total_male > 0 || $total_female > 0 || $total_unknown > 0) {
$data[] = [
I18N::translate('Males'),
- $tot_m
+ $total_male
];
$data[] = [
I18N::translate('Females'),
- $tot_f
+ $total_female
];
$data[] = [
I18N::translate('Unknown'),
- $tot_u
+ $total_unknown
];
}
diff --git a/app/Statistics/Repository/BrowserRepository.php b/app/Statistics/Repository/BrowserRepository.php
index 2232443c80..6e9c3bf1d3 100644
--- a/app/Statistics/Repository/BrowserRepository.php
+++ b/app/Statistics/Repository/BrowserRepository.php
@@ -21,12 +21,8 @@ namespace Fisharebest\Webtrees\Statistics\Repository;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Registry;
-use Fisharebest\Webtrees\Statistics\Repository\Interfaces\BrowserRepositoryInterface;
-/**
- * A repository providing methods for browser related statistics.
- */
-class BrowserRepository implements BrowserRepositoryInterface
+class BrowserRepository
{
public function browserDate(): string
{
diff --git a/app/Statistics/Repository/ContactRepository.php b/app/Statistics/Repository/ContactRepository.php
index ace3d3c042..86d4e2fd69 100644
--- a/app/Statistics/Repository/ContactRepository.php
+++ b/app/Statistics/Repository/ContactRepository.php
@@ -21,15 +21,11 @@ namespace Fisharebest\Webtrees\Statistics\Repository;
use Fisharebest\Webtrees\Registry;
use Fisharebest\Webtrees\Services\UserService;
-use Fisharebest\Webtrees\Statistics\Repository\Interfaces\ContactRepositoryInterface;
use Fisharebest\Webtrees\Tree;
use Fisharebest\Webtrees\User;
use Psr\Http\Message\ServerRequestInterface;
-/**
- * A repository providing methods for contact related statistics.
- */
-class ContactRepository implements ContactRepositoryInterface
+class ContactRepository
{
private Tree $tree;
diff --git a/app/Statistics/Repository/EventRepository.php b/app/Statistics/Repository/EventRepository.php
index fc8006a60b..29457a5ac0 100644
--- a/app/Statistics/Repository/EventRepository.php
+++ b/app/Statistics/Repository/EventRepository.php
@@ -30,7 +30,6 @@ use Fisharebest\Webtrees\Header;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Individual;
use Fisharebest\Webtrees\Registry;
-use Fisharebest\Webtrees\Statistics\Repository\Interfaces\EventRepositoryInterface;
use Fisharebest\Webtrees\Tree;
use Illuminate\Database\Query\JoinClause;
@@ -41,10 +40,7 @@ use function e;
use function strncmp;
use function substr;
-/**
- * A repository providing methods for event related statistics.
- */
-class EventRepository implements EventRepositoryInterface
+class EventRepository
{
/**
* Sorting directions.
@@ -107,9 +103,7 @@ class EventRepository implements EventRepositoryInterface
*/
public function totalEvents(array $events = []): string
{
- return I18N::number(
- $this->getEventCount($events)
- );
+ return I18N::number($this->getEventCount($events));
}
public function totalEventsBirth(): string
diff --git a/app/Statistics/Repository/FamilyDatesRepository.php b/app/Statistics/Repository/FamilyDatesRepository.php
index f88856cd96..a05129a6ce 100644
--- a/app/Statistics/Repository/FamilyDatesRepository.php
+++ b/app/Statistics/Repository/FamilyDatesRepository.php
@@ -25,17 +25,13 @@ use Fisharebest\Webtrees\Fact;
use Fisharebest\Webtrees\GedcomRecord;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Registry;
-use Fisharebest\Webtrees\Statistics\Repository\Interfaces\FamilyDatesRepositoryInterface;
use Fisharebest\Webtrees\Tree;
use Illuminate\Database\Query\Builder;
use function abs;
use function e;
-/**
- * A repository providing methods for family dates related statistics (birth, death, marriage, divorce).
- */
-class FamilyDatesRepository implements FamilyDatesRepositoryInterface
+class FamilyDatesRepository
{
/**
* Sorting directions.
@@ -92,8 +88,6 @@ class FamilyDatesRepository implements FamilyDatesRepositoryInterface
*
* @param string $type The fact to query
* @param string $operation The sorting operation
- *
- * @return string
*/
private function getFirstLastEvent(string $type, string $operation): string
{
@@ -158,8 +152,6 @@ class FamilyDatesRepository implements FamilyDatesRepositoryInterface
*
* @param string $type The fact to query
* @param string $operation The sorting operation
- *
- * @return string
*/
private function getFirstLastEventYear(string $type, string $operation): string
{
@@ -222,8 +214,6 @@ class FamilyDatesRepository implements FamilyDatesRepositoryInterface
*
* @param string $type The fact to query
* @param string $operation The sorting operation
- *
- * @return string
*/
private function getFirstLastEventName(string $type, string $operation): string
{
@@ -285,8 +275,6 @@ class FamilyDatesRepository implements FamilyDatesRepositoryInterface
*
* @param string $type The fact to query
* @param string $operation The sorting operation
- *
- * @return string
*/
private function getFirstLastEventPlace(string $type, string $operation): string
{
diff --git a/app/Statistics/Repository/FamilyRepository.php b/app/Statistics/Repository/FamilyRepository.php
index 5588b21790..e08a24d699 100644
--- a/app/Statistics/Repository/FamilyRepository.php
+++ b/app/Statistics/Repository/FamilyRepository.php
@@ -59,11 +59,6 @@ class FamilyRepository
private Tree $tree;
- /**
- * @param CenturyService $century_service
- * @param ColorService $color_service
- * @param Tree $tree
- */
public function __construct(CenturyService $century_service, ColorService $color_service, Tree $tree)
{
$this->century_service = $century_service;
@@ -71,13 +66,6 @@ class FamilyRepository
$this->tree = $tree;
}
- /**
- * General query on family.
- *
- * @param string $type
- *
- * @return string
- */
private function familyQuery(string $type): string
{
$row = DB::table('families')
@@ -108,41 +96,22 @@ class FamilyRepository
}
}
- /**
- * Find the family with the most children.
- *
- * @return string
- */
public function largestFamily(): string
{
return $this->familyQuery('full');
}
- /**
- * Find the number of children in the largest family.
- *
- * @return string
- */
public function largestFamilySize(): string
{
return $this->familyQuery('size');
}
- /**
- * Find the family with the most children.
- *
- * @return string
- */
public function largestFamilyName(): string
{
return $this->familyQuery('name');
}
/**
- * Find the couple with the most grandchildren.
- *
- * @param int $total
- *
* @return array<array<string,int|Family>>
*/
private function topTenGrandFamilyQuery(int $total): array
@@ -188,13 +157,6 @@ class FamilyRepository
->all();
}
- /**
- * Find the couple with the most grandchildren.
- *
- * @param int $total
- *
- * @return string
- */
public function topTenLargestGrandFamily(int $total = 10): string
{
return view('statistics/families/top10-nolist-grand', [
@@ -202,13 +164,6 @@ class FamilyRepository
]);
}
- /**
- * Find the couple with the most grandchildren.
- *
- * @param int $total
- *
- * @return string
- */
public function topTenLargestGrandFamilyList(int $total = 10): string
{
return view('statistics/families/top10-list-grand', [
@@ -216,11 +171,6 @@ class FamilyRepository
]);
}
- /**
- * Find the families with no children.
- *
- * @return int
- */
private function noChildrenFamiliesQuery(): int
{
return DB::table('families')
@@ -229,23 +179,11 @@ class FamilyRepository
->count();
}
- /**
- * Find the families with no children.
- *
- * @return string
- */
public function noChildrenFamilies(): string
{
return I18N::number($this->noChildrenFamiliesQuery());
}
- /**
- * Find the families with no children.
- *
- * @param string $type
- *
- * @return string
- */
public function noChildrenFamiliesList(string $type = 'list'): string
{
$families = DB::table('families')
@@ -278,14 +216,6 @@ class FamilyRepository
return $top10;
}
- /**
- * Create a chart of children with no families.
- *
- * @param int $year1
- * @param int $year2
- *
- * @return string
- */
public function chartNoChildrenFamilies(int $year1 = -1, int $year2 = -1): string
{
$no_child_fam = $this->noChildrenFamiliesQuery();
@@ -295,11 +225,7 @@ class FamilyRepository
}
/**
- * Returns the ages between siblings.
- *
- * @param int $total The total number of records to query
- *
- * @return array<object>
+ * @return array<object{family:string,child1:string,child2:string,age:int}>
*/
private function ageBetweenSiblingsQuery(int $total): array
{
@@ -327,10 +253,16 @@ class FamilyRepository
->where('link1.l_type', '=', 'CHIL')
->where('link1.l_file', '=', $this->tree->id())
->distinct()
- ->select(['link1.l_from AS family', 'link1.l_to AS ch1', 'link2.l_to AS ch2', new Expression(DB::prefix('child2.d_julianday2') . ' - ' . DB::prefix('child1.d_julianday1') . ' AS age')])
+ ->select(['link1.l_from AS family', 'link1.l_to AS child1', 'link2.l_to AS child2', new Expression(DB::prefix('child2.d_julianday2') . ' - ' . DB::prefix('child1.d_julianday1') . ' AS age')])
->orderBy('age', 'DESC')
->take($total)
->get()
+ ->map(static fn (object $row): object => (object) [
+ 'family' => $row->family,
+ 'child1' => $row->child1,
+ 'child2' => $row->child2,
+ 'age' => (int) $row->age,
+ ])
->all();
}
@@ -338,8 +270,6 @@ class FamilyRepository
* Returns the calculated age the time of event.
*
* @param int $age The age from the database record
- *
- * @return string
*/
private function calculateAge(int $age): string
{
@@ -372,8 +302,8 @@ class FamilyRepository
foreach ($rows as $fam) {
$family = Registry::familyFactory()->make($fam->family, $this->tree);
- $child1 = Registry::individualFactory()->make($fam->ch1, $this->tree);
- $child2 = Registry::individualFactory()->make($fam->ch2, $this->tree);
+ $child1 = Registry::individualFactory()->make($fam->child1, $this->tree);
+ $child2 = Registry::individualFactory()->make($fam->child2, $this->tree);
if ($family !== null && $child1 !== null && $child2 !== null && $child1->canShow() && $child2->canShow()) {
// ! Single array (no list)
@@ -381,7 +311,7 @@ class FamilyRepository
'child1' => $child1,
'child2' => $child2,
'family' => $family,
- 'age' => $this->calculateAge((int) $fam->age),
+ 'age' => $this->calculateAge($fam->age),
];
}
}
@@ -395,7 +325,7 @@ class FamilyRepository
* @param int $total The total number of records to query
* @param bool $one Include each family only once if true
*
- * @return array<int,array<string,Individual|Family|string>>
+ * @return array<int,array{family:Family,child1:Individual,child2:Individual,age:string}>
* @throws Exception
*/
private function ageBetweenSiblingsList(int $total, bool $one): array
@@ -404,14 +334,14 @@ class FamilyRepository
$top10 = [];
$dist = [];
- foreach ($rows as $fam) {
- $family = Registry::familyFactory()->make($fam->family, $this->tree);
- $child1 = Registry::individualFactory()->make($fam->ch1, $this->tree);
- $child2 = Registry::individualFactory()->make($fam->ch2, $this->tree);
+ foreach ($rows as $row) {
+ $family = Registry::familyFactory()->make($row->family, $this->tree);
+ $child1 = Registry::individualFactory()->make($row->child1, $this->tree);
+ $child2 = Registry::individualFactory()->make($row->child2, $this->tree);
- $age = $this->calculateAge((int) $fam->age);
+ $age = $this->calculateAge($row->age);
- if ($one && !in_array($fam->family, $dist, true)) {
+ if ($one && !in_array($row->family, $dist, true)) {
if ($family !== null && $child1 !== null && $child2 !== null && $child1->canShow() && $child2->canShow()) {
$top10[] = [
'child1' => $child1,
@@ -420,7 +350,7 @@ class FamilyRepository
'age' => $age,
];
- $dist[] = $fam->family;
+ $dist[] = $row->family;
}
} elseif (!$one && $family !== null && $child1 !== null && $child2 !== null && $child1->canShow() && $child2->canShow()) {
$top10[] = [
@@ -439,15 +369,13 @@ class FamilyRepository
* Find the ages between siblings.
*
* @param int $total The total number of records to query
- *
- * @return string
*/
private function ageBetweenSiblingsAge(int $total): string
{
$rows = $this->ageBetweenSiblingsQuery($total);
foreach ($rows as $fam) {
- return $this->calculateAge((int) $fam->age);
+ return $this->calculateAge($fam->age);
}
return '';
@@ -457,9 +385,6 @@ class FamilyRepository
* Find the ages between siblings.
*
* @param int $total The total number of records to query
- *
- * @return string
- * @throws Exception
*/
private function ageBetweenSiblingsName(int $total): string
{
@@ -467,8 +392,8 @@ class FamilyRepository
foreach ($rows as $fam) {
$family = Registry::familyFactory()->make($fam->family, $this->tree);
- $child1 = Registry::individualFactory()->make($fam->ch1, $this->tree);
- $child2 = Registry::individualFactory()->make($fam->ch2, $this->tree);
+ $child1 = Registry::individualFactory()->make($fam->child1, $this->tree);
+ $child2 = Registry::individualFactory()->make($fam->child2, $this->tree);
if ($family !== null && $child1 !== null && $child2 !== null && $child1->canShow() && $child2->canShow()) {
$return = '<a href="' . e($child2->url()) . '">' . $child2->fullName() . '</a> ';
@@ -485,37 +410,16 @@ class FamilyRepository
return '';
}
- /**
- * Find the names of siblings with the widest age gap.
- *
- * @param int $total
- *
- * @return string
- */
public function topAgeBetweenSiblingsName(int $total = 10): string
{
return $this->ageBetweenSiblingsName($total);
}
- /**
- * Find the widest age gap between siblings.
- *
- * @param int $total
- *
- * @return string
- */
public function topAgeBetweenSiblings(int $total = 10): string
{
return $this->ageBetweenSiblingsAge($total);
}
- /**
- * Find the name of siblings with the widest age gap.
- *
- * @param int $total
- *
- * @return string
- */
public function topAgeBetweenSiblingsFullName(int $total = 10): string
{
$record = $this->ageBetweenSiblingsNoList($total);
@@ -529,14 +433,6 @@ class FamilyRepository
]);
}
- /**
- * Find the siblings with the widest age gaps.
- *
- * @param int $total
- * @param string $one
- *
- * @return string
- */
public function topAgeBetweenSiblingsList(int $total = 10, string $one = ''): string
{
$records = $this->ageBetweenSiblingsList($total, (bool) $one);
@@ -576,22 +472,12 @@ class FamilyRepository
->all();
}
- /**
- * Genearl query on families/children.
- *
- * @return string
- */
public function statsChildren(): string
{
return (new ChartChildren($this->century_service, $this->tree))
->chartChildren();
}
- /**
- * Count the total children.
- *
- * @return string
- */
public function totalChildren(): string
{
$total = (int) DB::table('families')
@@ -601,11 +487,6 @@ class FamilyRepository
return I18N::number($total);
}
- /**
- * Find the average number of children in families.
- *
- * @return string
- */
public function averageChildren(): string
{
$average = (float) DB::table('families')
@@ -616,10 +497,6 @@ class FamilyRepository
}
/**
- * General query on families.
- *
- * @param int $total
- *
* @return array<array<string,mixed>>
*/
private function topTenFamilyQuery(int $total): array
@@ -638,13 +515,6 @@ class FamilyRepository
->all();
}
- /**
- * The the families with the most children.
- *
- * @param int $total
- *
- * @return string
- */
public function topTenLargestFamily(int $total = 10): string
{
$records = $this->topTenFamilyQuery($total);
@@ -654,13 +524,6 @@ class FamilyRepository
]);
}
- /**
- * Find the families with the most children.
- *
- * @param int $total
- *
- * @return string
- */
public function topTenLargestFamilyList(int $total = 10): string
{
$records = $this->topTenFamilyQuery($total);
@@ -670,15 +533,6 @@ class FamilyRepository
]);
}
- /**
- * Create a chart of the largest families.
- *
- * @param string|null $color_from
- * @param string|null $color_to
- * @param int $total
- *
- * @return string
- */
public function chartLargestFamilies(
string|null $color_from = null,
string|null $color_to = null,
@@ -688,14 +542,6 @@ class FamilyRepository
->chartLargestFamilies($color_from, $color_to, $total);
}
- /**
- * Find the month in the year of the birth of the first child.
- *
- * @param int $year1
- * @param int $year2
- *
- * @return Builder
- */
public function monthFirstChildQuery(int $year1 = -1, int $year2 = -1): Builder
{
$first_child_subquery = DB::table('link')
@@ -734,14 +580,6 @@ class FamilyRepository
return $query;
}
- /**
- * Find the month in the year of the birth of the first child.
- *
- * @param int $year1
- * @param int $year2
- *
- * @return Builder
- */
public function monthFirstChildBySexQuery(int $year1 = -1, int $year2 = -1): Builder
{
return $this->monthFirstChildQuery($year1, $year2)
@@ -754,11 +592,6 @@ class FamilyRepository
->groupBy(['d_month', 'i_sex']);
}
- /**
- * Number of husbands.
- *
- * @return string
- */
public function totalMarriedMales(): string
{
$n = DB::table('families')
@@ -770,11 +603,6 @@ class FamilyRepository
return I18N::number($n);
}
- /**
- * Number of wives.
- *
- * @return string
- */
public function totalMarriedFemales(): string
{
$n = DB::table('families')
@@ -786,16 +614,6 @@ class FamilyRepository
return I18N::number($n);
}
- /**
- * General query on parents.
- *
- * @param string $type
- * @param string $age_dir
- * @param string $sex
- * @param bool $show_years
- *
- * @return string
- */
private function parentsQuery(string $type, string $age_dir, string $sex, bool $show_years): string
{
if ($sex === 'F') {
@@ -872,129 +690,61 @@ class FamilyRepository
return $result;
}
- /**
- * Find the youngest mother
- *
- * @return string
- */
public function youngestMother(): string
{
return $this->parentsQuery('full', 'ASC', 'F', false);
}
- /**
- * Find the name of the youngest mother.
- *
- * @return string
- */
public function youngestMotherName(): string
{
return $this->parentsQuery('name', 'ASC', 'F', false);
}
- /**
- * Find the age of the youngest mother.
- *
- * @param string $show_years
- *
- * @return string
- */
public function youngestMotherAge(string $show_years = ''): string
{
return $this->parentsQuery('age', 'ASC', 'F', (bool) $show_years);
}
- /**
- * Find the oldest mother.
- *
- * @return string
- */
public function oldestMother(): string
{
return $this->parentsQuery('full', 'DESC', 'F', false);
}
- /**
- * Find the name of the oldest mother.
- *
- * @return string
- */
public function oldestMotherName(): string
{
return $this->parentsQuery('name', 'DESC', 'F', false);
}
- /**
- * Find the age of the oldest mother.
- *
- * @param string $show_years
- *
- * @return string
- */
public function oldestMotherAge(string $show_years = ''): string
{
return $this->parentsQuery('age', 'DESC', 'F', (bool) $show_years);
}
- /**
- * Find the youngest father.
- *
- * @return string
- */
public function youngestFather(): string
{
return $this->parentsQuery('full', 'ASC', 'M', false);
}
- /**
- * Find the name of the youngest father.
- *
- * @return string
- */
public function youngestFatherName(): string
{
return $this->parentsQuery('name', 'ASC', 'M', false);
}
- /**
- * Find the age of the youngest father.
- *
- * @param string $show_years
- *
- * @return string
- */
public function youngestFatherAge(string $show_years = ''): string
{
return $this->parentsQuery('age', 'ASC', 'M', (bool) $show_years);
}
- /**
- * Find the oldest father.
- *
- * @return string
- */
public function oldestFather(): string
{
return $this->parentsQuery('full', 'DESC', 'M', false);
}
- /**
- * Find the name of the oldest father.
- *
- * @return string
- */
public function oldestFatherName(): string
{
return $this->parentsQuery('name', 'DESC', 'M', false);
}
- /**
- * Find the age of the oldest father.
- *
- * @param string $show_years
- *
- * @return string
- */
public function oldestFatherAge(string $show_years = ''): string
{
return $this->parentsQuery('age', 'DESC', 'M', (bool) $show_years);
@@ -1006,8 +756,6 @@ class FamilyRepository
* @param string $type
* @param string $age_dir "ASC" or "DESC"
* @param int $total
- *
- * @return string
*/
private function ageOfMarriageQuery(string $type, string $age_dir, int $total): string
{
@@ -1164,101 +912,48 @@ class FamilyRepository
return $top10;
}
- /**
- * General query on marriage ages.
- *
- * @return string
- */
public function topAgeOfMarriageFamily(): string
{
return $this->ageOfMarriageQuery('name', 'DESC', 1);
}
- /**
- * General query on marriage ages.
- *
- * @return string
- */
public function topAgeOfMarriage(): string
{
return $this->ageOfMarriageQuery('age', 'DESC', 1);
}
- /**
- * General query on marriage ages.
- *
- * @param int $total
- *
- * @return string
- */
public function topAgeOfMarriageFamilies(int $total = 10): string
{
return $this->ageOfMarriageQuery('nolist', 'DESC', $total);
}
- /**
- * General query on marriage ages.
- *
- * @param int $total
- *
- * @return string
- */
public function topAgeOfMarriageFamiliesList(int $total = 10): string
{
return $this->ageOfMarriageQuery('list', 'DESC', $total);
}
- /**
- * General query on marriage ages.
- *
- * @return string
- */
public function minAgeOfMarriageFamily(): string
{
return $this->ageOfMarriageQuery('name', 'ASC', 1);
}
- /**
- * General query on marriage ages.
- *
- * @return string
- */
public function minAgeOfMarriage(): string
{
return $this->ageOfMarriageQuery('age', 'ASC', 1);
}
- /**
- * General query on marriage ages.
- *
- * @param int $total
- *
- * @return string
- */
public function minAgeOfMarriageFamilies(int $total = 10): string
{
return $this->ageOfMarriageQuery('nolist', 'ASC', $total);
}
- /**
- * General query on marriage ages.
- *
- * @param int $total
- *
- * @return string
- */
public function minAgeOfMarriageFamiliesList(int $total = 10): string
{
return $this->ageOfMarriageQuery('list', 'ASC', $total);
}
/**
- * Find the ages between spouses.
- *
- * @param string $age_dir
- * @param int $total
- *
- * @return array<array<string,mixed>>
+ * @return array<array{family:Family,age:string}>
*/
private function ageBetweenSpousesQuery(string $age_dir, int $total): array
{
@@ -1314,13 +1009,6 @@ class FamilyRepository
->all();
}
- /**
- * Find the age between husband and wife.
- *
- * @param int $total
- *
- * @return string
- */
public function ageBetweenSpousesMF(int $total = 10): string
{
$records = $this->ageBetweenSpousesQuery('DESC', $total);
@@ -1330,13 +1018,6 @@ class FamilyRepository
]);
}
- /**
- * Find the age between husband and wife.
- *
- * @param int $total
- *
- * @return string
- */
public function ageBetweenSpousesMFList(int $total = 10): string
{
$records = $this->ageBetweenSpousesQuery('DESC', $total);
@@ -1346,13 +1027,6 @@ class FamilyRepository
]);
}
- /**
- * Find the age between wife and husband..
- *
- * @param int $total
- *
- * @return string
- */
public function ageBetweenSpousesFM(int $total = 10): string
{
$records = $this->ageBetweenSpousesQuery('ASC', $total);
@@ -1362,13 +1036,6 @@ class FamilyRepository
]);
}
- /**
- * Find the age between wife and husband..
- *
- * @param int $total
- *
- * @return string
- */
public function ageBetweenSpousesFMList(int $total = 10): string
{
$records = $this->ageBetweenSpousesQuery('ASC', $total);
@@ -1430,8 +1097,6 @@ class FamilyRepository
* @param string $age_dir "ASC" or "DESC"
* @param string $sex "F" or "M"
* @param bool $show_years
- *
- * @return string
*/
private function marriageQuery(string $type, string $age_dir, string $sex, bool $show_years): string
{
@@ -1509,142 +1174,66 @@ class FamilyRepository
return $result;
}
- /**
- * Find the youngest wife.
- *
- * @return string
- */
public function youngestMarriageFemale(): string
{
return $this->marriageQuery('full', 'ASC', 'F', false);
}
- /**
- * Find the name of the youngest wife.
- *
- * @return string
- */
public function youngestMarriageFemaleName(): string
{
return $this->marriageQuery('name', 'ASC', 'F', false);
}
- /**
- * Find the age of the youngest wife.
- *
- * @param string $show_years
- *
- * @return string
- */
public function youngestMarriageFemaleAge(string $show_years = ''): string
{
return $this->marriageQuery('age', 'ASC', 'F', (bool) $show_years);
}
- /**
- * Find the oldest wife.
- *
- * @return string
- */
public function oldestMarriageFemale(): string
{
return $this->marriageQuery('full', 'DESC', 'F', false);
}
- /**
- * Find the name of the oldest wife.
- *
- * @return string
- */
public function oldestMarriageFemaleName(): string
{
return $this->marriageQuery('name', 'DESC', 'F', false);
}
- /**
- * Find the age of the oldest wife.
- *
- * @param string $show_years
- *
- * @return string
- */
public function oldestMarriageFemaleAge(string $show_years = ''): string
{
return $this->marriageQuery('age', 'DESC', 'F', (bool) $show_years);
}
- /**
- * Find the youngest husband.
- *
- * @return string
- */
public function youngestMarriageMale(): string
{
return $this->marriageQuery('full', 'ASC', 'M', false);
}
- /**
- * Find the name of the youngest husband.
- *
- * @return string
- */
public function youngestMarriageMaleName(): string
{
return $this->marriageQuery('name', 'ASC', 'M', false);
}
- /**
- * Find the age of the youngest husband.
- *
- * @param string $show_years
- *
- * @return string
- */
public function youngestMarriageMaleAge(string $show_years = ''): string
{
return $this->marriageQuery('age', 'ASC', 'M', (bool) $show_years);
}
- /**
- * Find the oldest husband.
- *
- * @return string
- */
public function oldestMarriageMale(): string
{
return $this->marriageQuery('full', 'DESC', 'M', false);
}
- /**
- * Find the name of the oldest husband.
- *
- * @return string
- */
public function oldestMarriageMaleName(): string
{
return $this->marriageQuery('name', 'DESC', 'M', false);
}
- /**
- * Find the age of the oldest husband.
- *
- * @param string $show_years
- *
- * @return string
- */
public function oldestMarriageMaleAge(string $show_years = ''): string
{
return $this->marriageQuery('age', 'DESC', 'M', (bool) $show_years);
}
- /**
- * General query on marriages.
- *
- * @param int $year1
- * @param int $year2
- *
- * @return Builder
- */
public function statsMarriageQuery(int $year1 = -1, int $year2 = -1): Builder
{
$query = DB::table('dates')
@@ -1660,14 +1249,6 @@ class FamilyRepository
return $query;
}
- /**
- * General query on marriages.
- *
- * @param int $year1
- * @param int $year2
- *
- * @return Builder
- */
public function statsFirstMarriageQuery(int $year1 = -1, int $year2 = -1): Builder
{
$query = DB::table('families')
@@ -1690,28 +1271,12 @@ class FamilyRepository
->orderBy('d_julianday2');
}
- /**
- * General query on marriages.
- *
- * @param string|null $color_from
- * @param string|null $color_to
- *
- * @return string
- */
public function statsMarr(string|null $color_from = null, string|null $color_to = null): string
{
return (new ChartMarriage($this->century_service, $this->color_service, $this->tree))
->chartMarriage($color_from, $color_to);
}
- /**
- * General divorce query.
- *
- * @param string|null $color_from
- * @param string|null $color_to
- *
- * @return string
- */
public function statsDiv(string|null $color_from = null, string|null $color_to = null): string
{
return (new ChartDivorce($this->century_service, $this->color_service, $this->tree))
diff --git a/app/Statistics/Repository/FavoritesRepository.php b/app/Statistics/Repository/FavoritesRepository.php
index ea96ceb3c1..b6d1b04143 100644
--- a/app/Statistics/Repository/FavoritesRepository.php
+++ b/app/Statistics/Repository/FavoritesRepository.php
@@ -25,24 +25,16 @@ use Fisharebest\Webtrees\Module\FamilyTreeFavoritesModule;
use Fisharebest\Webtrees\Module\ModuleBlockInterface;
use Fisharebest\Webtrees\Module\UserFavoritesModule;
use Fisharebest\Webtrees\Services\ModuleService;
-use Fisharebest\Webtrees\Statistics\Repository\Interfaces\FavoritesRepositoryInterface;
use Fisharebest\Webtrees\Tree;
use function count;
-/**
- * A repository providing methods for favorites related statistics.
- */
-class FavoritesRepository implements FavoritesRepositoryInterface
+class FavoritesRepository
{
private Tree $tree;
private ModuleService $module_service;
- /**
- * @param Tree $tree
- * @param ModuleService $module_service
- */
public function __construct(Tree $tree, ModuleService $module_service)
{
$this->tree = $tree;
diff --git a/app/Statistics/Repository/GedcomRepository.php b/app/Statistics/Repository/GedcomRepository.php
index e2ba64b39e..0a088e6588 100644
--- a/app/Statistics/Repository/GedcomRepository.php
+++ b/app/Statistics/Repository/GedcomRepository.php
@@ -24,7 +24,6 @@ use Fisharebest\Webtrees\DB;
use Fisharebest\Webtrees\Fact;
use Fisharebest\Webtrees\Header;
use Fisharebest\Webtrees\Registry;
-use Fisharebest\Webtrees\Statistics\Repository\Interfaces\GedcomRepositoryInterface;
use Fisharebest\Webtrees\Tree;
use InvalidArgumentException;
@@ -33,16 +32,10 @@ use function str_contains;
use function strpos;
use function substr;
-/**
- * A repository providing methods for GEDCOM related statistics.
- */
-class GedcomRepository implements GedcomRepositoryInterface
+class GedcomRepository
{
private Tree $tree;
- /**
- * @param Tree $tree
- */
public function __construct(Tree $tree)
{
$this->tree = $tree;
@@ -83,9 +76,6 @@ class GedcomRepository implements GedcomRepositoryInterface
return $this->tree->name();
}
- /**
- * @return int
- */
public function gedcomId(): int
{
return $this->tree->id();
@@ -120,10 +110,6 @@ class GedcomRepository implements GedcomRepositoryInterface
return $head[1];
}
- /**
- * @return string
- * @throws Exception
- */
public function gedcomDate(): string
{
$head = Registry::headerFactory()->make('HEAD', $this->tree);
diff --git a/app/Statistics/Repository/HitCountRepository.php b/app/Statistics/Repository/HitCountRepository.php
index c6e4775755..66c57e7f8a 100644
--- a/app/Statistics/Repository/HitCountRepository.php
+++ b/app/Statistics/Repository/HitCountRepository.php
@@ -23,15 +23,11 @@ use Fisharebest\Webtrees\Auth;
use Fisharebest\Webtrees\Contracts\UserInterface;
use Fisharebest\Webtrees\DB;
use Fisharebest\Webtrees\Services\UserService;
-use Fisharebest\Webtrees\Statistics\Repository\Interfaces\HitCountRepositoryInterface;
use Fisharebest\Webtrees\Tree;
use function view;
-/**
- * A repository providing methods for hit count related statistics.
- */
-class HitCountRepository implements HitCountRepositoryInterface
+class HitCountRepository
{
private Tree $tree;
diff --git a/app/Statistics/Repository/IndividualRepository.php b/app/Statistics/Repository/IndividualRepository.php
index 5454f49b59..182c8e8def 100644
--- a/app/Statistics/Repository/IndividualRepository.php
+++ b/app/Statistics/Repository/IndividualRepository.php
@@ -39,7 +39,6 @@ use Fisharebest\Webtrees\Statistics\Google\ChartFamilyWithSources;
use Fisharebest\Webtrees\Statistics\Google\ChartIndividualWithSources;
use Fisharebest\Webtrees\Statistics\Google\ChartMortality;
use Fisharebest\Webtrees\Statistics\Google\ChartSex;
-use Fisharebest\Webtrees\Statistics\Repository\Interfaces\IndividualRepositoryInterface;
use Fisharebest\Webtrees\Statistics\Service\CenturyService;
use Fisharebest\Webtrees\Statistics\Service\ColorService;
use Fisharebest\Webtrees\Tree;
@@ -61,10 +60,7 @@ use function preg_match;
use function uksort;
use function view;
-/**
- * A repository providing methods for individual related statistics.
- */
-class IndividualRepository implements IndividualRepositoryInterface
+class IndividualRepository
{
private CenturyService $century_service;
diff --git a/app/Statistics/Repository/Interfaces/BrowserRepositoryInterface.php b/app/Statistics/Repository/Interfaces/BrowserRepositoryInterface.php
deleted file mode 100644
index 9307495156..0000000000
--- a/app/Statistics/Repository/Interfaces/BrowserRepositoryInterface.php
+++ /dev/null
@@ -1,29 +0,0 @@
-<?php
-
-/**
- * webtrees: online genealogy
- * Copyright (C) 2025 webtrees development team
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-declare(strict_types=1);
-
-namespace Fisharebest\Webtrees\Statistics\Repository\Interfaces;
-
-interface BrowserRepositoryInterface
-{
- public function browserDate(): string;
-
- public function browserTime(): string;
-
- public function browserTimezone(): string;
-}
diff --git a/app/Statistics/Repository/Interfaces/ContactRepositoryInterface.php b/app/Statistics/Repository/Interfaces/ContactRepositoryInterface.php
deleted file mode 100644
index b295323369..0000000000
--- a/app/Statistics/Repository/Interfaces/ContactRepositoryInterface.php
+++ /dev/null
@@ -1,27 +0,0 @@
-<?php
-
-/**
- * webtrees: online genealogy
- * Copyright (C) 2025 webtrees development team
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-declare(strict_types=1);
-
-namespace Fisharebest\Webtrees\Statistics\Repository\Interfaces;
-
-interface ContactRepositoryInterface
-{
- public function contactWebmaster(): string;
-
- public function contactGedcom(): string;
-}
diff --git a/app/Statistics/Repository/Interfaces/EventRepositoryInterface.php b/app/Statistics/Repository/Interfaces/EventRepositoryInterface.php
deleted file mode 100644
index 84570c89b6..0000000000
--- a/app/Statistics/Repository/Interfaces/EventRepositoryInterface.php
+++ /dev/null
@@ -1,66 +0,0 @@
-<?php
-
-/**
- * webtrees: online genealogy
- * Copyright (C) 2025 webtrees development team
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-declare(strict_types=1);
-
-namespace Fisharebest\Webtrees\Statistics\Repository\Interfaces;
-
-interface EventRepositoryInterface
-{
- /**
- * @param array<string> $events
- */
- public function totalEvents(array $events = []): string;
-
- public function totalEventsBirth(): string;
-
- public function totalBirths(): string;
-
- public function totalEventsDeath(): string;
-
- public function totalDeaths(): string;
-
- public function totalEventsMarriage(): string;
-
- public function totalMarriages(): string;
-
- public function totalEventsDivorce(): string;
-
- public function totalDivorces(): string;
-
- public function totalEventsOther(): string;
-
- public function firstEvent(): string;
-
- public function lastEvent(): string;
-
- public function firstEventYear(): string;
-
- public function lastEventYear(): string;
-
- public function firstEventType(): string;
-
- public function lastEventType(): string;
-
- public function firstEventName(): string;
-
- public function lastEventName(): string;
-
- public function firstEventPlace(): string;
-
- public function lastEventPlace(): string;
-}
diff --git a/app/Statistics/Repository/Interfaces/FamilyDatesRepositoryInterface.php b/app/Statistics/Repository/Interfaces/FamilyDatesRepositoryInterface.php
deleted file mode 100644
index 0b7761ba5e..0000000000
--- a/app/Statistics/Repository/Interfaces/FamilyDatesRepositoryInterface.php
+++ /dev/null
@@ -1,87 +0,0 @@
-<?php
-
-/**
- * webtrees: online genealogy
- * Copyright (C) 2025 webtrees development team
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-declare(strict_types=1);
-
-namespace Fisharebest\Webtrees\Statistics\Repository\Interfaces;
-
-interface FamilyDatesRepositoryInterface
-{
- public function firstBirth(): string;
-
- public function firstBirthYear(): string;
-
- public function firstBirthName(): string;
-
- public function firstBirthPlace(): string;
-
- public function lastBirth(): string;
-
- public function lastBirthYear(): string;
-
- public function lastBirthName(): string;
-
- public function lastBirthPlace(): string;
-
- public function firstDeath(): string;
-
- public function firstDeathYear(): string;
-
- public function firstDeathName(): string;
-
- public function firstDeathPlace(): string;
-
- public function lastDeath(): string;
-
- public function lastDeathYear(): string;
-
- public function lastDeathName(): string;
-
- public function lastDeathPlace(): string;
-
- public function firstMarriage(): string;
-
- public function firstMarriageYear(): string;
-
- public function firstMarriageName(): string;
-
- public function firstMarriagePlace(): string;
-
- public function lastMarriage(): string;
-
- public function lastMarriageYear(): string;
-
- public function lastMarriageName(): string;
-
- public function lastMarriagePlace(): string;
-
- public function firstDivorce(): string;
-
- public function firstDivorceYear(): string;
-
- public function firstDivorceName(): string;
-
- public function firstDivorcePlace(): string;
-
- public function lastDivorce(): string;
-
- public function lastDivorceYear(): string;
-
- public function lastDivorceName(): string;
-
- public function lastDivorcePlace(): string;
-}
diff --git a/app/Statistics/Repository/Interfaces/FavoritesRepositoryInterface.php b/app/Statistics/Repository/Interfaces/FavoritesRepositoryInterface.php
deleted file mode 100644
index 7ae806da4f..0000000000
--- a/app/Statistics/Repository/Interfaces/FavoritesRepositoryInterface.php
+++ /dev/null
@@ -1,31 +0,0 @@
-<?php
-
-/**
- * webtrees: online genealogy
- * Copyright (C) 2025 webtrees development team
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-declare(strict_types=1);
-
-namespace Fisharebest\Webtrees\Statistics\Repository\Interfaces;
-
-interface FavoritesRepositoryInterface
-{
- public function gedcomFavorites(): string;
-
- public function userFavorites(): string;
-
- public function totalGedcomFavorites(): string;
-
- public function totalUserFavorites(): string;
-}
diff --git a/app/Statistics/Repository/Interfaces/GedcomRepositoryInterface.php b/app/Statistics/Repository/Interfaces/GedcomRepositoryInterface.php
deleted file mode 100644
index 296f130ac3..0000000000
--- a/app/Statistics/Repository/Interfaces/GedcomRepositoryInterface.php
+++ /dev/null
@@ -1,39 +0,0 @@
-<?php
-
-/**
- * webtrees: online genealogy
- * Copyright (C) 2025 webtrees development team
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-declare(strict_types=1);
-
-namespace Fisharebest\Webtrees\Statistics\Repository\Interfaces;
-
-interface GedcomRepositoryInterface
-{
- public function gedcomFilename(): string;
-
- public function gedcomId(): int;
-
- public function gedcomTitle(): string;
-
- public function gedcomCreatedSoftware(): string;
-
- public function gedcomCreatedVersion(): string;
-
- public function gedcomDate(): string;
-
- public function gedcomUpdated(): string;
-
- public function gedcomRootId(): string;
-}
diff --git a/app/Statistics/Repository/Interfaces/HitCountRepositoryInterface.php b/app/Statistics/Repository/Interfaces/HitCountRepositoryInterface.php
deleted file mode 100644
index 35c2a28717..0000000000
--- a/app/Statistics/Repository/Interfaces/HitCountRepositoryInterface.php
+++ /dev/null
@@ -1,39 +0,0 @@
-<?php
-
-/**
- * webtrees: online genealogy
- * Copyright (C) 2025 webtrees development team
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-declare(strict_types=1);
-
-namespace Fisharebest\Webtrees\Statistics\Repository\Interfaces;
-
-interface HitCountRepositoryInterface
-{
- public function hitCount(string $page_parameter = ''): string;
-
- public function hitCountUser(string $page_parameter = ''): string;
-
- public function hitCountIndi(string $page_parameter = ''): string;
-
- public function hitCountFam(string $page_parameter = ''): string;
-
- public function hitCountSour(string $page_parameter = ''): string;
-
- public function hitCountRepo(string $page_parameter = ''): string;
-
- public function hitCountNote(string $page_parameter = ''): string;
-
- public function hitCountObje(string $page_parameter = ''): string;
-}
diff --git a/app/Statistics/Repository/Interfaces/IndividualRepositoryInterface.php b/app/Statistics/Repository/Interfaces/IndividualRepositoryInterface.php
deleted file mode 100644
index 60129ae4fb..0000000000
--- a/app/Statistics/Repository/Interfaces/IndividualRepositoryInterface.php
+++ /dev/null
@@ -1,73 +0,0 @@
-<?php
-
-/**
- * webtrees: online genealogy
- * Copyright (C) 2025 webtrees development team
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-declare(strict_types=1);
-
-namespace Fisharebest\Webtrees\Statistics\Repository\Interfaces;
-
-interface IndividualRepositoryInterface
-{
- public function totalRecords(): string;
-
- public function totalIndividuals(): string;
-
- public function totalSexMales(): string;
-
- public function totalSexFemales(): string;
-
- public function totalSexUnknown(): string;
-
- public function totalFamilies(): string;
-
- public function totalRepositories(): string;
-
- public function totalSources(): string;
-
- public function totalNotes(): string;
-
- public function totalIndividualsPercentage(): string;
-
- public function totalIndisWithSourcesPercentage(): string;
-
- public function totalFamiliesPercentage(): string;
-
- public function totalFamsWithSourcesPercentage(): string;
-
- public function totalRepositoriesPercentage(): string;
-
- public function totalSourcesPercentage(): string;
-
- public function totalNotesPercentage(): string;
-
- public function totalLivingPercentage(): string;
-
- public function totalDeceasedPercentage(): string;
-
- public function totalSexMalesPercentage(): string;
-
- public function totalSexFemalesPercentage(): string;
-
- public function totalSexUnknownPercentage(): string;
-
- public function getCommonSurname(): string;
-
- public function chartSex(
- string|null $color_female = null,
- string|null $color_male = null,
- string|null $color_unknown = null
- ): string;
-}
diff --git a/app/Statistics/Repository/Interfaces/LatestUserRepositoryInterface.php b/app/Statistics/Repository/Interfaces/LatestUserRepositoryInterface.php
deleted file mode 100644
index a6cde3b68f..0000000000
--- a/app/Statistics/Repository/Interfaces/LatestUserRepositoryInterface.php
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php
-
-/**
- * webtrees: online genealogy
- * Copyright (C) 2025 webtrees development team
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-declare(strict_types=1);
-
-namespace Fisharebest\Webtrees\Statistics\Repository\Interfaces;
-
-interface LatestUserRepositoryInterface
-{
- public function latestUserId(): string;
-
- public function latestUserName(): string;
-
- public function latestUserFullName(): string;
-
- public function latestUserRegDate(string|null $format = null): string;
-
- public function latestUserRegTime(string|null $format = null): string;
-
- public function latestUserLoggedin(string|null $yes = null, string|null $no = null): string;
-}
diff --git a/app/Statistics/Repository/Interfaces/MediaRepositoryInterface.php b/app/Statistics/Repository/Interfaces/MediaRepositoryInterface.php
deleted file mode 100644
index 14049c8c58..0000000000
--- a/app/Statistics/Repository/Interfaces/MediaRepositoryInterface.php
+++ /dev/null
@@ -1,65 +0,0 @@
-<?php
-
-/**
- * webtrees: online genealogy
- * Copyright (C) 2025 webtrees development team
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-declare(strict_types=1);
-
-namespace Fisharebest\Webtrees\Statistics\Repository\Interfaces;
-
-interface MediaRepositoryInterface
-{
- public function totalMedia(): string;
-
- public function totalMediaAudio(): string;
-
- public function totalMediaBook(): string;
-
- public function totalMediaCard(): string;
-
- public function totalMediaCertificate(): string;
-
- public function totalMediaCoatOfArms(): string;
-
- public function totalMediaDocument(): string;
-
- public function totalMediaElectronic(): string;
-
- public function totalMediaMagazine(): string;
-
- public function totalMediaManuscript(): string;
-
- public function totalMediaMap(): string;
-
- public function totalMediaFiche(): string;
-
- public function totalMediaFilm(): string;
-
- public function totalMediaNewspaper(): string;
-
- public function totalMediaPainting(): string;
-
- public function totalMediaPhoto(): string;
-
- public function totalMediaTombstone(): string;
-
- public function totalMediaVideo(): string;
-
- public function totalMediaOther(): string;
-
- public function totalMediaUnknown(): string;
-
- public function chartMedia(string|null $color_from = null, string|null $color_to = null): string;
-}
diff --git a/app/Statistics/Repository/Interfaces/MessageRepositoryInterface.php b/app/Statistics/Repository/Interfaces/MessageRepositoryInterface.php
deleted file mode 100644
index 6a8e1206f0..0000000000
--- a/app/Statistics/Repository/Interfaces/MessageRepositoryInterface.php
+++ /dev/null
@@ -1,25 +0,0 @@
-<?php
-
-/**
- * webtrees: online genealogy
- * Copyright (C) 2025 webtrees development team
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-declare(strict_types=1);
-
-namespace Fisharebest\Webtrees\Statistics\Repository\Interfaces;
-
-interface MessageRepositoryInterface
-{
- public function totalUserMessages(): string;
-}
diff --git a/app/Statistics/Repository/Interfaces/NewsRepositoryInterface.php b/app/Statistics/Repository/Interfaces/NewsRepositoryInterface.php
deleted file mode 100644
index 5458470e80..0000000000
--- a/app/Statistics/Repository/Interfaces/NewsRepositoryInterface.php
+++ /dev/null
@@ -1,27 +0,0 @@
-<?php
-
-/**
- * webtrees: online genealogy
- * Copyright (C) 2025 webtrees development team
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-declare(strict_types=1);
-
-namespace Fisharebest\Webtrees\Statistics\Repository\Interfaces;
-
-interface NewsRepositoryInterface
-{
- public function totalUserJournal(): string;
-
- public function totalGedcomNews(): string;
-}
diff --git a/app/Statistics/Repository/Interfaces/PlaceRepositoryInterface.php b/app/Statistics/Repository/Interfaces/PlaceRepositoryInterface.php
deleted file mode 100644
index 44061c664c..0000000000
--- a/app/Statistics/Repository/Interfaces/PlaceRepositoryInterface.php
+++ /dev/null
@@ -1,39 +0,0 @@
-<?php
-
-/**
- * webtrees: online genealogy
- * Copyright (C) 2025 webtrees development team
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-declare(strict_types=1);
-
-namespace Fisharebest\Webtrees\Statistics\Repository\Interfaces;
-
-interface PlaceRepositoryInterface
-{
- public function commonBirthPlacesList(): string;
-
- public function commonDeathPlacesList(): string;
-
- public function commonMarriagePlacesList(): string;
-
- public function commonCountriesList(): string;
-
- public function totalPlaces(): string;
-
- public function chartDistribution(
- string $chart_shows = 'world',
- string $chart_type = '',
- string $surname = ''
- ): string;
-}
diff --git a/app/Statistics/Repository/Interfaces/ServerRepositoryInterface.php b/app/Statistics/Repository/Interfaces/ServerRepositoryInterface.php
deleted file mode 100644
index 5d437462cd..0000000000
--- a/app/Statistics/Repository/Interfaces/ServerRepositoryInterface.php
+++ /dev/null
@@ -1,31 +0,0 @@
-<?php
-
-/**
- * webtrees: online genealogy
- * Copyright (C) 2025 webtrees development team
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-declare(strict_types=1);
-
-namespace Fisharebest\Webtrees\Statistics\Repository\Interfaces;
-
-interface ServerRepositoryInterface
-{
- public function serverDate(): string;
-
- public function serverTime(): string;
-
- public function serverTime24(): string;
-
- public function serverTimezone(): string;
-}
diff --git a/app/Statistics/Repository/Interfaces/UserRepositoryInterface.php b/app/Statistics/Repository/Interfaces/UserRepositoryInterface.php
deleted file mode 100644
index abec53fb00..0000000000
--- a/app/Statistics/Repository/Interfaces/UserRepositoryInterface.php
+++ /dev/null
@@ -1,45 +0,0 @@
-<?php
-
-/**
- * webtrees: online genealogy
- * Copyright (C) 2025 webtrees development team
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-declare(strict_types=1);
-
-namespace Fisharebest\Webtrees\Statistics\Repository\Interfaces;
-
-interface UserRepositoryInterface
-{
- public function usersLoggedIn(): string;
-
- public function usersLoggedInList(): string;
-
- public function usersLoggedInTotal(): int;
-
- public function usersLoggedInTotalAnon(): int;
-
- public function usersLoggedInTotalVisible(): int;
-
- public function userId(): string;
-
- public function userName(string $visitor_text = ''): string;
-
- public function userFullName(): string;
-
- public function totalUsers(): string;
-
- public function totalAdmins(): string;
-
- public function totalNonAdmins(): string;
-}
diff --git a/app/Statistics/Repository/LatestUserRepository.php b/app/Statistics/Repository/LatestUserRepository.php
index 9760d9bd2f..787156da0d 100644
--- a/app/Statistics/Repository/LatestUserRepository.php
+++ b/app/Statistics/Repository/LatestUserRepository.php
@@ -25,7 +25,6 @@ use Fisharebest\Webtrees\DB;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Registry;
use Fisharebest\Webtrees\Services\UserService;
-use Fisharebest\Webtrees\Statistics\Repository\Interfaces\LatestUserRepositoryInterface;
use Illuminate\Database\Query\Builder;
use Illuminate\Database\Query\JoinClause;
@@ -33,10 +32,7 @@ use function date;
use function e;
use function str_replace;
-/**
- * A repository providing methods for latest user related statistics.
- */
-class LatestUserRepository implements LatestUserRepositoryInterface
+class LatestUserRepository
{
private UserService $user_service;
diff --git a/app/Statistics/Repository/MediaRepository.php b/app/Statistics/Repository/MediaRepository.php
index 7c64870761..f82e43283d 100644
--- a/app/Statistics/Repository/MediaRepository.php
+++ b/app/Statistics/Repository/MediaRepository.php
@@ -22,15 +22,11 @@ namespace Fisharebest\Webtrees\Statistics\Repository;
use Fisharebest\Webtrees\DB;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Statistics\Google\ChartMedia;
-use Fisharebest\Webtrees\Statistics\Repository\Interfaces\MediaRepositoryInterface;
use Fisharebest\Webtrees\Statistics\Service\ColorService;
use Fisharebest\Webtrees\Tree;
use Illuminate\Database\Query\Expression;
-/**
- * A repository providing methods for media type related statistics.
- */
-class MediaRepository implements MediaRepositoryInterface
+class MediaRepository
{
private ColorService $color_service;
diff --git a/app/Statistics/Repository/MessageRepository.php b/app/Statistics/Repository/MessageRepository.php
index f48ca1f312..af8c2c6ffa 100644
--- a/app/Statistics/Repository/MessageRepository.php
+++ b/app/Statistics/Repository/MessageRepository.php
@@ -22,12 +22,8 @@ namespace Fisharebest\Webtrees\Statistics\Repository;
use Fisharebest\Webtrees\Auth;
use Fisharebest\Webtrees\DB;
use Fisharebest\Webtrees\I18N;
-use Fisharebest\Webtrees\Statistics\Repository\Interfaces\MessageRepositoryInterface;
-/**
- * A repository providing methods for user message related statistics.
- */
-class MessageRepository implements MessageRepositoryInterface
+class MessageRepository
{
public function totalUserMessages(): string
{
diff --git a/app/Statistics/Repository/NewsRepository.php b/app/Statistics/Repository/NewsRepository.php
index a19f8128ab..92e754d832 100644
--- a/app/Statistics/Repository/NewsRepository.php
+++ b/app/Statistics/Repository/NewsRepository.php
@@ -22,13 +22,9 @@ namespace Fisharebest\Webtrees\Statistics\Repository;
use Fisharebest\Webtrees\Auth;
use Fisharebest\Webtrees\DB;
use Fisharebest\Webtrees\I18N;
-use Fisharebest\Webtrees\Statistics\Repository\Interfaces\NewsRepositoryInterface;
use Fisharebest\Webtrees\Tree;
-/**
- * A repository providing methods for news related statistics.
- */
-class NewsRepository implements NewsRepositoryInterface
+class NewsRepository
{
private Tree $tree;
diff --git a/app/Statistics/Repository/PlaceRepository.php b/app/Statistics/Repository/PlaceRepository.php
index c025619e5e..480329e130 100644
--- a/app/Statistics/Repository/PlaceRepository.php
+++ b/app/Statistics/Repository/PlaceRepository.php
@@ -23,8 +23,6 @@ use Fisharebest\Webtrees\DB;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Place;
use Fisharebest\Webtrees\Statistics\Google\ChartDistribution;
-use Fisharebest\Webtrees\Statistics\Repository\Interfaces\IndividualRepositoryInterface;
-use Fisharebest\Webtrees\Statistics\Repository\Interfaces\PlaceRepositoryInterface;
use Fisharebest\Webtrees\Statistics\Service\CountryService;
use Fisharebest\Webtrees\Tree;
use Illuminate\Database\Query\Expression;
@@ -38,18 +36,18 @@ use function view;
/**
* A repository providing methods for place related statistics.
*/
-class PlaceRepository implements PlaceRepositoryInterface
+class PlaceRepository
{
private Tree $tree;
private CountryService $country_service;
- private IndividualRepositoryInterface $individual_repository;
+ private IndividualRepository $individual_repository;
public function __construct(
Tree $tree,
CountryService $country_service,
- IndividualRepositoryInterface $individual_repository
+ IndividualRepository $individual_repository
) {
$this->tree = $tree;
$this->country_service = $country_service;
diff --git a/app/Statistics/Repository/ServerRepository.php b/app/Statistics/Repository/ServerRepository.php
index 9c20eba3e5..4624338efd 100644
--- a/app/Statistics/Repository/ServerRepository.php
+++ b/app/Statistics/Repository/ServerRepository.php
@@ -22,12 +22,8 @@ namespace Fisharebest\Webtrees\Statistics\Repository;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Registry;
use Fisharebest\Webtrees\SiteUser;
-use Fisharebest\Webtrees\Statistics\Repository\Interfaces\ServerRepositoryInterface;
-/**
- * A repository providing methods for server related statistics.
- */
-class ServerRepository implements ServerRepositoryInterface
+class ServerRepository
{
public function serverDate(): string
{
diff --git a/app/Statistics/Repository/UserRepository.php b/app/Statistics/Repository/UserRepository.php
index 7afabf065d..9513f12f73 100644
--- a/app/Statistics/Repository/UserRepository.php
+++ b/app/Statistics/Repository/UserRepository.php
@@ -27,7 +27,6 @@ use Fisharebest\Webtrees\Individual;
use Fisharebest\Webtrees\Registry;
use Fisharebest\Webtrees\Services\MessageService;
use Fisharebest\Webtrees\Services\UserService;
-use Fisharebest\Webtrees\Statistics\Repository\Interfaces\UserRepositoryInterface;
use Fisharebest\Webtrees\Tree;
use function count;
@@ -35,10 +34,7 @@ use function e;
use function route;
use function view;
-/**
- * A repository providing methods for user related statistics.
- */
-class UserRepository implements UserRepositoryInterface
+class UserRepository
{
private Tree $tree;
diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index 2879fd1c9d..51d02de5a0 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -8143,18 +8143,6 @@ parameters:
path: app/Statistics/Google/ChartDivorce.php
-
- message: '#^Access to an undefined property object\:\:\$id\.$#'
- identifier: property.notFound
- count: 1
- path: app/Statistics/Google/ChartFamilyLargest.php
-
- -
- message: '#^Access to an undefined property object\:\:\$total\.$#'
- identifier: property.notFound
- count: 1
- path: app/Statistics/Google/ChartFamilyLargest.php
-
- -
message: '#^Parameter \#1 \$xref of method Fisharebest\\Webtrees\\Contracts\\FamilyFactoryInterface\:\:make\(\) expects string, mixed given\.$#'
identifier: argument.type
count: 1
@@ -8293,36 +8281,12 @@ parameters:
path: app/Statistics/Repository/FamilyDatesRepository.php
-
- message: '#^Access to an undefined property object\:\:\$age\.$#'
- identifier: property.notFound
- count: 3
- path: app/Statistics/Repository/FamilyRepository.php
-
- -
- message: '#^Access to an undefined property object\:\:\$ch1\.$#'
- identifier: property.notFound
- count: 3
- path: app/Statistics/Repository/FamilyRepository.php
-
- -
- message: '#^Access to an undefined property object\:\:\$ch2\.$#'
- identifier: property.notFound
- count: 3
- path: app/Statistics/Repository/FamilyRepository.php
-
- -
message: '#^Access to an undefined property object\:\:\$f_numchil\.$#'
identifier: property.notFound
count: 1
path: app/Statistics/Repository/FamilyRepository.php
-
- message: '#^Access to an undefined property object\:\:\$family\.$#'
- identifier: property.notFound
- count: 5
- path: app/Statistics/Repository/FamilyRepository.php
-
- -
message: '#^Binary operation "/" between mixed and 365\.25 results in an error\.$#'
identifier: binaryOp.invalid
count: 2
@@ -8391,7 +8355,13 @@ parameters:
-
message: '#^Cannot cast mixed to int\.$#'
identifier: cast.int
- count: 11
+ count: 9
+ path: app/Statistics/Repository/FamilyRepository.php
+
+ -
+ message: '#^Method Fisharebest\\Webtrees\\Statistics\\Repository\\FamilyRepository\:\:ageBetweenSiblingsQuery\(\) should return array\<object\{family\: string, child1\: string, child2\: string, age\: int\}\> but returns array\<int, object\{family\: mixed, child1\: mixed, child2\: mixed, age\: int\}&stdClass\>\.$#'
+ identifier: return.type
+ count: 1
path: app/Statistics/Repository/FamilyRepository.php
-
@@ -8403,13 +8373,13 @@ parameters:
-
message: '#^Parameter \#1 \$xref of method Fisharebest\\Webtrees\\Contracts\\FamilyFactoryInterface\:\:make\(\) expects string, mixed given\.$#'
identifier: argument.type
- count: 4
+ count: 1
path: app/Statistics/Repository/FamilyRepository.php
-
message: '#^Parameter \#1 \$xref of method Fisharebest\\Webtrees\\Contracts\\IndividualFactoryInterface\:\:make\(\) expects string, mixed given\.$#'
identifier: argument.type
- count: 8
+ count: 2
path: app/Statistics/Repository/FamilyRepository.php
-