X7ROOT File Manager
Current Path:
/home/prisjneg/public_html/vendor/symfony/string/Inflector
home
/
prisjneg
/
public_html
/
vendor
/
symfony
/
string
/
Inflector
/
馃搧
..
馃搫
EnglishInflector.php
(16.89 KB)
馃搫
FrenchInflector.php
(5.82 KB)
馃搫
InflectorInterface.php
(835 B)
馃搫
SpanishInflector.php
(3.52 KB)
Editing: SpanishInflector.php
<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\String\Inflector; final class SpanishInflector implements InflectorInterface { /** * A list of all rules for pluralise. * * @see https://www.spanishdict.com/guide/spanish-plural-noun-forms * @see https://www.rae.es/gram%C3%A1tica/morfolog%C3%ADa/la-formaci%C3%B3n-del-plural-plurales-en-s-y-plurales-en-es-reglas-generales */ // First entry: regex // Second entry: replacement private const PLURALIZE_REGEXP = [ // Specials s铆, no ['/(s铆|no)$/i', '\1es'], // Words ending with vowel must use -s (RAE 3.2a, 3.2c) ['/(a|e|i|o|u|谩|茅|铆|贸|煤)$/i', '\1s'], // Word ending in s or x and the previous letter is accented (RAE 3.2n) ['/谩s$/i', 'ases'], ['/茅s$/i', 'eses'], ['/铆s$/i', 'ises'], ['/贸s$/i', 'oses'], ['/煤s$/i', 'uses'], // Words ending in -i贸n must changed to -iones ['/i贸n$/i', '\1iones'], // Words ending in some consonants must use -es (RAE 3.2k) ['/(l|r|n|d|j|s|x|ch|y)$/i', '\1es'], // Word ending in z, must changed to ces ['/(z)$/i', 'ces'], ]; /** * A list of all rules for singularize. */ private const SINGULARIZE_REGEXP = [ // Specials s铆, no ['/(s铆|no)es$/i', '\1'], // Words ending in -i贸n must changed to -iones ['/iones$/i', '\1i贸n'], // Word ending in z, must changed to ces ['/ces$/i', 'z'], // Word ending in s or x and the previous letter is accented (RAE 3.2n) ['/(\w)ases$/i', '\1谩s'], ['/eses$/i', '茅s'], ['/ises$/i', '铆s'], ['/(\w{2,})oses$/i', '\1贸s'], ['/(\w)uses$/i', '\1煤s'], // Words ending in some consonants and -es, must be the consonants ['/(l|r|n|d|j|s|x|ch|y)e?s$/i', '\1'], // Words ended with vowel and s, must be vowel ['/(a|e|i|o|u|谩|茅|贸|铆|煤)s$/i', '\1'], ]; private const UNINFLECTED_RULES = [ // Words ending with pies (RAE 3.2n) '/.*(pi茅s)$/i', ]; private const UNINFLECTED = '/^(lunes|martes|mi茅rcoles|jueves|viernes|an谩lisis|torax|yo|pies)$/i'; public function singularize(string $plural): array { if ($this->isInflectedWord($plural)) { return [$plural]; } foreach (self::SINGULARIZE_REGEXP as $rule) { [$regexp, $replace] = $rule; if (1 === preg_match($regexp, $plural)) { return [preg_replace($regexp, $replace, $plural)]; } } return [$plural]; } public function pluralize(string $singular): array { if ($this->isInflectedWord($singular)) { return [$singular]; } foreach (self::PLURALIZE_REGEXP as $rule) { [$regexp, $replace] = $rule; if (1 === preg_match($regexp, $singular)) { return [preg_replace($regexp, $replace, $singular)]; } } return [$singular.'s']; } private function isInflectedWord(string $word): bool { foreach (self::UNINFLECTED_RULES as $rule) { if (1 === preg_match($rule, $word)) { return true; } } return 1 === preg_match(self::UNINFLECTED, $word); } }
Upload File
Create Folder