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