Failed Conditions
Pull Request — master (#97)
by Jonathan
03:14
created

Plural::getDefaultTransformations()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 27

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 26
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 27
ccs 26
cts 26
cp 1
rs 9.488
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Inflector\Rules;
6
7
class Plural
8
{
9
    /**
10
     * @return Transformation[]
11
     */
12 524
    public static function getDefaultTransformations() : iterable
13
    {
14 524
        yield new Transformation(new Pattern('/(s)tatus$/i'), '\1\2tatuses');
15 524
        yield new Transformation(new Pattern('/(quiz)$/i'), '\1zes');
16 524
        yield new Transformation(new Pattern('/^(ox)$/i'), '\1\2en');
17 524
        yield new Transformation(new Pattern('/([m|l])ouse$/i'), '\1ice');
18 524
        yield new Transformation(new Pattern('/(matr|vert|ind)(ix|ex)$/i'), '\1ices');
19 524
        yield new Transformation(new Pattern('/(x|ch|ss|sh)$/i'), '\1es');
20 524
        yield new Transformation(new Pattern('/([^aeiouy]|qu)y$/i'), '\1ies');
21 524
        yield new Transformation(new Pattern('/(hive|gulf)$/i'), '\1s');
22 524
        yield new Transformation(new Pattern('/(?:([^f])fe|([lr])f)$/i'), '\1\2ves');
23 524
        yield new Transformation(new Pattern('/sis$/i'), 'ses');
24 524
        yield new Transformation(new Pattern('/([ti])um$/i'), '\1a');
25 524
        yield new Transformation(new Pattern('/(tax)on$/i'), '\1a');
26 524
        yield new Transformation(new Pattern('/(c)riterion$/i'), '\1riteria');
27 524
        yield new Transformation(new Pattern('/(p)erson$/i'), '\1eople');
28 524
        yield new Transformation(new Pattern('/(m)an$/i'), '\1en');
29 524
        yield new Transformation(new Pattern('/(c)hild$/i'), '\1hildren');
30 524
        yield new Transformation(new Pattern('/(f)oot$/i'), '\1eet');
31 524
        yield new Transformation(new Pattern('/(buffal|her|potat|tomat|volcan)o$/i'), '\1\2oes');
32 524
        yield new Transformation(new Pattern('/(alumn|bacill|cact|foc|fung|nucle|radi|stimul|syllab|termin|vir)us$/i'), '\1i');
33 524
        yield new Transformation(new Pattern('/us$/i'), 'uses');
34 524
        yield new Transformation(new Pattern('/(alias)$/i'), '\1es');
35 524
        yield new Transformation(new Pattern('/(analys|ax|cris|test|thes)is$/i'), '\1es');
36 524
        yield new Transformation(new Pattern('/s$/'), 's');
37 524
        yield new Transformation(new Pattern('/^$/'), '');
38 524
        yield new Transformation(new Pattern('/$/'), 's');
39 524
    }
40
41
    /**
42
     * @return Word[]
43
     */
44 524
    public static function getUninflectedWords() : iterable
45
    {
46 524
        yield new Word('.*[nrlm]ese');
47 524
        yield new Word('.*deer');
48 524
        yield new Word('.*fish');
49 524
        yield new Word('.*measles');
50 524
        yield new Word('.*ois');
51 524
        yield new Word('.*pox');
52 524
        yield new Word('.*sheep');
53 524
        yield new Word('people');
54 524
        yield new Word('police');
55 524
        yield new Word('middleware');
56 524
    }
57
58
    /**
59
     * @return Substitution[]
60
     */
61 526
    public static function getIrregularRules() : iterable
62
    {
63 526
        yield new Substitution(new Word('atlas'), new Word('atlases'));
64 526
        yield new Substitution(new Word('axe'), new Word('axes'));
65 526
        yield new Substitution(new Word('beef'), new Word('beefs'));
66 526
        yield new Substitution(new Word('brother'), new Word('brothers'));
67 526
        yield new Substitution(new Word('cafe'), new Word('cafes'));
68 526
        yield new Substitution(new Word('chateau'), new Word('chateaux'));
69 526
        yield new Substitution(new Word('niveau'), new Word('niveaux'));
70 526
        yield new Substitution(new Word('child'), new Word('children'));
71 526
        yield new Substitution(new Word('cookie'), new Word('cookies'));
72 526
        yield new Substitution(new Word('corpus'), new Word('corpuses'));
73 526
        yield new Substitution(new Word('cow'), new Word('cows'));
74 526
        yield new Substitution(new Word('criterion'), new Word('criteria'));
75 526
        yield new Substitution(new Word('curriculum'), new Word('curricula'));
76 526
        yield new Substitution(new Word('demo'), new Word('demos'));
77 526
        yield new Substitution(new Word('domino'), new Word('dominoes'));
78 526
        yield new Substitution(new Word('echo'), new Word('echoes'));
79 526
        yield new Substitution(new Word('foot'), new Word('feet'));
80 526
        yield new Substitution(new Word('fungus'), new Word('fungi'));
81 526
        yield new Substitution(new Word('ganglion'), new Word('ganglions'));
82 526
        yield new Substitution(new Word('genie'), new Word('genies'));
83 526
        yield new Substitution(new Word('genus'), new Word('genera'));
84 526
        yield new Substitution(new Word('goose'), new Word('geese'));
85 526
        yield new Substitution(new Word('graffito'), new Word('graffiti'));
86 526
        yield new Substitution(new Word('hippopotamus'), new Word('hippopotami'));
87 526
        yield new Substitution(new Word('hoof'), new Word('hoofs'));
88 526
        yield new Substitution(new Word('human'), new Word('humans'));
89 526
        yield new Substitution(new Word('iris'), new Word('irises'));
90 526
        yield new Substitution(new Word('larva'), new Word('larvae'));
91 526
        yield new Substitution(new Word('leaf'), new Word('leaves'));
92 526
        yield new Substitution(new Word('loaf'), new Word('loaves'));
93 526
        yield new Substitution(new Word('man'), new Word('men'));
94 526
        yield new Substitution(new Word('medium'), new Word('media'));
95 526
        yield new Substitution(new Word('memorandum'), new Word('memoranda'));
96 526
        yield new Substitution(new Word('money'), new Word('monies'));
97 526
        yield new Substitution(new Word('mongoose'), new Word('mongooses'));
98 526
        yield new Substitution(new Word('motto'), new Word('mottoes'));
99 526
        yield new Substitution(new Word('move'), new Word('moves'));
100 526
        yield new Substitution(new Word('mythos'), new Word('mythoi'));
101 526
        yield new Substitution(new Word('niche'), new Word('niches'));
102 526
        yield new Substitution(new Word('nucleus'), new Word('nuclei'));
103 526
        yield new Substitution(new Word('numen'), new Word('numina'));
104 526
        yield new Substitution(new Word('occiput'), new Word('occiputs'));
105 526
        yield new Substitution(new Word('octopus'), new Word('octopuses'));
106 526
        yield new Substitution(new Word('opus'), new Word('opuses'));
107 526
        yield new Substitution(new Word('ox'), new Word('oxen'));
108 526
        yield new Substitution(new Word('passerby'), new Word('passersby'));
109 526
        yield new Substitution(new Word('penis'), new Word('penises'));
110 526
        yield new Substitution(new Word('person'), new Word('people'));
111 526
        yield new Substitution(new Word('plateau'), new Word('plateaux'));
112 526
        yield new Substitution(new Word('runner-up'), new Word('runners-up'));
113 526
        yield new Substitution(new Word('safe'), new Word('safes'));
114 526
        yield new Substitution(new Word('sex'), new Word('sexes'));
115 526
        yield new Substitution(new Word('soliloquy'), new Word('soliloquies'));
116 526
        yield new Substitution(new Word('son-in-law'), new Word('sons-in-law'));
117 526
        yield new Substitution(new Word('syllabus'), new Word('syllabi'));
118 526
        yield new Substitution(new Word('testis'), new Word('testes'));
119 526
        yield new Substitution(new Word('thief'), new Word('thieves'));
120 526
        yield new Substitution(new Word('tooth'), new Word('teeth'));
121 526
        yield new Substitution(new Word('tornado'), new Word('tornadoes'));
122 526
        yield new Substitution(new Word('trilby'), new Word('trilbys'));
123 526
        yield new Substitution(new Word('turf'), new Word('turfs'));
124 526
        yield new Substitution(new Word('valve'), new Word('valves'));
125 526
        yield new Substitution(new Word('volcano'), new Word('volcanoes'));
126 526
    }
127
}
128