Passed
Push — master ( 1aedb3...c18c47 )
by Greg
11:36
created

Census::censusPlaces()   C

Complexity

Conditions 9
Paths 9

Size

Total Lines 94
Code Lines 80

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 9
eloc 80
c 1
b 0
f 0
nc 9
nop 1
dl 0
loc 94
rs 6.8808

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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
18
declare(strict_types=1);
19
20
namespace Fisharebest\Webtrees\Census;
21
22
/**
23
 * Definitions for a census
24
 */
25
class Census
26
{
27
    /**
28
     * @param string $locale
29
     *
30
     * @return CensusPlaceInterface[]
31
     */
32
    public static function censusPlaces(string $locale): array
33
    {
34
        switch ($locale) {
35
            case 'cs':
36
                return [
37
                    new CensusOfCzechRepublic(),
38
                    new CensusOfSlovakia(),
39
                    new CensusOfDenmark(),
40
                    new CensusOfDeutschland(),
41
                    new CensusOfEngland(),
42
                    new CensusOfFrance(),
43
                    new CensusOfScotland(),
44
                    new CensusOfUnitedStates(),
45
                    new CensusOfWales(),
46
                ];
47
48
            case 'en-AU':
49
            case 'en-GB':
50
                return [
51
                    new CensusOfEngland(),
52
                    new CensusOfScotland(),
53
                    new CensusOfWales(),
54
                    new CensusOfUnitedStates(),
55
                    new CensusOfCzechRepublic(),
56
                    new CensusOfDenmark(),
57
                    new CensusOfDeutschland(),
58
                    new CensusOfFrance(),
59
                    new CensusOfSlovakia(),
60
                ];
61
62
            case 'en-US':
63
                return [
64
                    new CensusOfUnitedStates(),
65
                    new CensusOfCzechRepublic(),
66
                    new CensusOfDenmark(),
67
                    new CensusOfDeutschland(),
68
                    new CensusOfEngland(),
69
                    new CensusOfFrance(),
70
                    new CensusOfScotland(),
71
                    new CensusOfSlovakia(),
72
                    new CensusOfWales(),
73
                ];
74
75
            case 'fr':
76
            case 'fr-CA':
77
                return [
78
                    new CensusOfFrance(),
79
                    new CensusOfCzechRepublic(),
80
                    new CensusOfDenmark(),
81
                    new CensusOfDeutschland(),
82
                    new CensusOfEngland(),
83
                    new CensusOfScotland(),
84
                    new CensusOfSlovakia(),
85
                    new CensusOfUnitedStates(),
86
                    new CensusOfWales(),
87
                ];
88
89
            case 'da':
90
                return [
91
                    new CensusOfDenmark(),
92
                    new CensusOfDeutschland(),
93
                    new CensusOfCzechRepublic(),
94
                    new CensusOfEngland(),
95
                    new CensusOfFrance(),
96
                    new CensusOfScotland(),
97
                    new CensusOfSlovakia(),
98
                    new CensusOfUnitedStates(),
99
                    new CensusOfWales(),
100
                ];
101
102
            case 'de':
103
                return [
104
                    new CensusOfDeutschland(),
105
                    new CensusOfCzechRepublic(),
106
                    new CensusOfDenmark(),
107
                    new CensusOfEngland(),
108
                    new CensusOfFrance(),
109
                    new CensusOfScotland(),
110
                    new CensusOfSlovakia(),
111
                    new CensusOfUnitedStates(),
112
                    new CensusOfWales(),
113
                ];
114
115
            default:
116
                return [
117
                    new CensusOfUnitedStates(),
118
                    new CensusOfEngland(),
119
                    new CensusOfScotland(),
120
                    new CensusOfWales(),
121
                    new CensusOfDeutschland(),
122
                    new CensusOfFrance(),
123
                    new CensusOfCzechRepublic(),
124
                    new CensusOfSlovakia(),
125
                    new CensusOfDenmark(),
126
                ];
127
        }
128
    }
129
}
130