|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Doctrine\Inflector\Rules\Spanish; |
|
6
|
|
|
|
|
7
|
|
|
use Doctrine\Inflector\Rules\Pattern; |
|
8
|
|
|
use Doctrine\Inflector\Rules\Substitution; |
|
9
|
|
|
use Doctrine\Inflector\Rules\Transformation; |
|
10
|
|
|
use Doctrine\Inflector\Rules\Word; |
|
11
|
|
|
|
|
12
|
|
|
class Inflectible |
|
13
|
|
|
{ |
|
14
|
|
|
/** |
|
15
|
|
|
* @return Transformation[] |
|
16
|
|
|
*/ |
|
17
|
72 |
|
public static function getSingular() : iterable |
|
18
|
|
|
{ |
|
19
|
72 |
|
yield new Transformation(new Pattern('/ereses$/'), 'erés'); |
|
20
|
72 |
|
yield new Transformation(new Pattern('/iones$/'), 'ión'); |
|
21
|
72 |
|
yield new Transformation(new Pattern('/ces$/'), 'z'); |
|
22
|
72 |
|
yield new Transformation(new Pattern('/es$/'), ''); |
|
23
|
72 |
|
yield new Transformation(new Pattern('/s$/'), ''); |
|
24
|
72 |
|
} |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @return Transformation[] |
|
28
|
|
|
*/ |
|
29
|
72 |
|
public static function getPlural() : iterable |
|
30
|
|
|
{ |
|
31
|
72 |
|
yield new Transformation(new Pattern('/ú([sn])$/i'), 'u\1es'); |
|
32
|
72 |
|
yield new Transformation(new Pattern('/ó([sn])$/i'), 'o\1es'); |
|
33
|
72 |
|
yield new Transformation(new Pattern('/í([sn])$/i'), 'i\1es'); |
|
34
|
72 |
|
yield new Transformation(new Pattern('/é([sn])$/i'), 'e\1es'); |
|
35
|
72 |
|
yield new Transformation(new Pattern('/á([sn])$/i'), 'a\1es'); |
|
36
|
72 |
|
yield new Transformation(new Pattern('/z$/i'), 'ces'); |
|
37
|
72 |
|
yield new Transformation(new Pattern('/([aeiou]s)$/i'), '\1'); |
|
38
|
72 |
|
yield new Transformation(new Pattern('/([^aeéiou])$/i'), '\1es'); |
|
39
|
72 |
|
yield new Transformation(new Pattern('/$/'), 's'); |
|
40
|
72 |
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @return Substitution[] |
|
44
|
|
|
*/ |
|
45
|
72 |
|
public static function getIrregular() : iterable |
|
46
|
|
|
{ |
|
47
|
72 |
|
yield new Substitution(new Word('el'), new Word('los')); |
|
48
|
72 |
|
yield new Substitution(new Word('papá'), new Word('papás')); |
|
49
|
72 |
|
yield new Substitution(new Word('mamá'), new Word('mamás')); |
|
50
|
72 |
|
yield new Substitution(new Word('sofá'), new Word('sofás')); |
|
51
|
72 |
|
yield new Substitution(new Word('mes'), new Word('meses')); |
|
52
|
72 |
|
} |
|
53
|
|
|
} |
|
54
|
|
|
|