xref: /webtrees/app/Census/Census.php (revision 8fcd0d32e56ee262912bbdb593202cfd1cbc1615)
140150762SGreg Roach<?php
240150762SGreg Roach/**
340150762SGreg Roach * webtrees: online genealogy
4*8fcd0d32SGreg Roach * Copyright (C) 2019 webtrees development team
540150762SGreg Roach * This program is free software: you can redistribute it and/or modify
640150762SGreg Roach * it under the terms of the GNU General Public License as published by
740150762SGreg Roach * the Free Software Foundation, either version 3 of the License, or
840150762SGreg Roach * (at your option) any later version.
940150762SGreg Roach * This program is distributed in the hope that it will be useful,
1040150762SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
1140150762SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1240150762SGreg Roach * GNU General Public License for more details.
1340150762SGreg Roach * You should have received a copy of the GNU General Public License
1440150762SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>.
1540150762SGreg Roach */
16e7f56f2aSGreg Roachdeclare(strict_types=1);
1715d603e7SGreg Roach
1840150762SGreg Roachnamespace Fisharebest\Webtrees\Census;
1940150762SGreg Roach
2040150762SGreg Roach/**
2140150762SGreg Roach * Definitions for a census
2240150762SGreg Roach */
23c1010edaSGreg Roachclass Census
24c1010edaSGreg Roach{
2540150762SGreg Roach    /**
26eaf61769SGreg Roach     * @param string $locale
27eaf61769SGreg Roach     *
2840150762SGreg Roach     * @return CensusPlaceInterface[]
2940150762SGreg Roach     */
308f53f488SRico Sonntag    public static function censusPlaces(string $locale): array
31c1010edaSGreg Roach    {
32eaf61769SGreg Roach        $all_census_places = [
3359f2f229SGreg Roach            new CensusOfCzechRepublic(),
3459f2f229SGreg Roach            new CensusOfDenmark(),
3559f2f229SGreg Roach            new CensusOfDeutschland(),
3659f2f229SGreg Roach            new CensusOfEngland(),
3759f2f229SGreg Roach            new CensusOfFrance(),
3859f2f229SGreg Roach            new CensusOfScotland(),
3959f2f229SGreg Roach            new CensusOfUnitedStates(),
4059f2f229SGreg Roach            new CensusOfWales(),
4113abd6f3SGreg Roach        ];
42eaf61769SGreg Roach
43eaf61769SGreg Roach        switch ($locale) {
44eaf61769SGreg Roach            case 'cs':
4559f2f229SGreg Roach                $census_places = [new CensusOfCzechRepublic()];
46eaf61769SGreg Roach                break;
47eaf61769SGreg Roach
48eaf61769SGreg Roach            case 'en-AU':
49eaf61769SGreg Roach            case 'en-GB':
50c1010edaSGreg Roach                $census_places = [
5159f2f229SGreg Roach                    new CensusOfEngland(),
5259f2f229SGreg Roach                    new CensusOfWales(),
5359f2f229SGreg Roach                    new CensusOfScotland(),
54c1010edaSGreg Roach                ];
55eaf61769SGreg Roach                break;
56eaf61769SGreg Roach
57eaf61769SGreg Roach            case 'en-US':
5859f2f229SGreg Roach                $census_places = [new CensusOfUnitedStates()];
59eaf61769SGreg Roach                break;
60eaf61769SGreg Roach
61eaf61769SGreg Roach            case 'fr':
62eaf61769SGreg Roach            case 'fr-CA':
6359f2f229SGreg Roach                $census_places = [new CensusOfFrance()];
64eaf61769SGreg Roach                break;
65eaf61769SGreg Roach
66eaf61769SGreg Roach            case 'da':
6759f2f229SGreg Roach                $census_places = [new CensusOfDenmark()];
68eaf61769SGreg Roach                break;
69eaf61769SGreg Roach
70eaf61769SGreg Roach            case 'de':
7159f2f229SGreg Roach                $census_places = [new CensusOfDeutschland()];
72eaf61769SGreg Roach                break;
73eaf61769SGreg Roach
74eaf61769SGreg Roach            default:
75eaf61769SGreg Roach                $census_places = [];
76eaf61769SGreg Roach                break;
77eaf61769SGreg Roach        }
78eaf61769SGreg Roach
79eaf61769SGreg Roach        foreach ($all_census_places as $census_place) {
80eaf61769SGreg Roach            if (!in_array($census_place, $census_places)) {
81eaf61769SGreg Roach                $census_places[] = $census_place;
82eaf61769SGreg Roach            }
83eaf61769SGreg Roach        }
84eaf61769SGreg Roach
85eaf61769SGreg Roach        return $census_places;
8640150762SGreg Roach    }
8740150762SGreg Roach}
88