xref: /webtrees/app/Census/Census.php (revision 8a1bc7bd114eff24967c00f631a566b662dd7d50)
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	 * @param string $locale
25	 *
26	 * @return CensusPlaceInterface[]
27	 */
28	public static function censusPlaces(string $locale) {
29		$all_census_places = [
30			new CensusOfCzechRepublic,
31			new CensusOfDenmark,
32			new CensusOfDeutschland,
33			new CensusOfEngland,
34			new CensusOfFrance,
35			new CensusOfScotland,
36			new CensusOfUnitedStates,
37			new CensusOfWales,
38		];
39
40		switch ($locale) {
41			case 'cs':
42				$census_places = [new CensusOfCzechRepublic];
43				break;
44
45			case 'en-AU':
46			case 'en-GB':
47				$census_places = [new CensusOfEngland, new CensusOfWales, new CensusOfScotland];
48				break;
49
50			case 'en-US':
51				$census_places = [new CensusOfUnitedStates];
52				break;
53
54			case 'fr':
55			case 'fr-CA':
56				$census_places = [new CensusOfFrance];
57				break;
58
59			case 'da':
60				$census_places = [new CensusOfDenmark];
61				break;
62
63			case 'de':
64				$census_places = [new CensusOfDeutschland];
65				break;
66
67			default:
68				$census_places = [];
69				break;
70
71		}
72
73		foreach ($all_census_places as $census_place) {
74			if (!in_array($census_place, $census_places)) {
75				$census_places[] = $census_place;
76			}
77		}
78
79		return $census_places;
80	}
81}
82