xref: /webtrees/app/Census/Census.php (revision 873953697c930fadbf3243d2b8c0029fd684da0e)
1<?php
2/**
3 * webtrees: online genealogy
4 * Copyright (C) 2018 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 */
16
17namespace Fisharebest\Webtrees\Census;
18
19/**
20 * Definitions for a census
21 */
22class Census
23{
24    /**
25     * @param string $locale
26     *
27     * @return CensusPlaceInterface[]
28     */
29    public static function censusPlaces(string $locale): array
30    {
31        $all_census_places = [
32            new CensusOfCzechRepublic(),
33            new CensusOfDenmark(),
34            new CensusOfDeutschland(),
35            new CensusOfEngland(),
36            new CensusOfFrance(),
37            new CensusOfScotland(),
38            new CensusOfUnitedStates(),
39            new CensusOfWales(),
40        ];
41
42        switch ($locale) {
43            case 'cs':
44                $census_places = [new CensusOfCzechRepublic()];
45                break;
46
47            case 'en-AU':
48            case 'en-GB':
49                $census_places = [
50                    new CensusOfEngland(),
51                    new CensusOfWales(),
52                    new CensusOfScotland(),
53                ];
54                break;
55
56            case 'en-US':
57                $census_places = [new CensusOfUnitedStates()];
58                break;
59
60            case 'fr':
61            case 'fr-CA':
62                $census_places = [new CensusOfFrance()];
63                break;
64
65            case 'da':
66                $census_places = [new CensusOfDenmark()];
67                break;
68
69            case 'de':
70                $census_places = [new CensusOfDeutschland()];
71                break;
72
73            default:
74                $census_places = [];
75                break;
76        }
77
78        foreach ($all_census_places as $census_place) {
79            if (!in_array($census_place, $census_places)) {
80                $census_places[] = $census_place;
81            }
82        }
83
84        return $census_places;
85    }
86}
87