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