xref: /webtrees/app/Census/Census.php (revision df27497a949ee94233b78915e33f253447a14e62)
1<?php
2
3/**
4 * webtrees: online genealogy
5 * Copyright (C) 2019 webtrees development team
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18declare(strict_types=1);
19
20namespace Fisharebest\Webtrees\Census;
21
22/**
23 * Definitions for a census
24 */
25class Census
26{
27    /**
28     * @param string $locale
29     *
30     * @return CensusPlaceInterface[]
31     */
32    public static function censusPlaces(string $locale): array
33    {
34        $all_census_places = [
35            new CensusOfCzechRepublic(),
36            new CensusOfDenmark(),
37            new CensusOfDeutschland(),
38            new CensusOfEngland(),
39            new CensusOfFrance(),
40            new CensusOfScotland(),
41            new CensusOfUnitedStates(),
42            new CensusOfWales(),
43        ];
44
45        switch ($locale) {
46            case 'cs':
47                $census_places = [new CensusOfCzechRepublic()];
48                break;
49
50            case 'en-AU':
51            case 'en-GB':
52                $census_places = [
53                    new CensusOfEngland(),
54                    new CensusOfWales(),
55                    new CensusOfScotland(),
56                ];
57                break;
58
59            case 'en-US':
60                $census_places = [new CensusOfUnitedStates()];
61                break;
62
63            case 'fr':
64            case 'fr-CA':
65                $census_places = [new CensusOfFrance()];
66                break;
67
68            case 'da':
69                $census_places = [new CensusOfDenmark()];
70                break;
71
72            case 'de':
73                $census_places = [new CensusOfDeutschland()];
74                break;
75
76            default:
77                $census_places = [];
78                break;
79        }
80
81        foreach ($all_census_places as $census_place) {
82            if (!in_array($census_place, $census_places, false)) {
83                $census_places[] = $census_place;
84            }
85        }
86
87        return $census_places;
88    }
89}
90