Addded pluralization and singularization exception for currency

This commit is contained in:
SilverFire - Dmitry Naumenko
2017-02-28 15:58:59 +02:00
parent a350b34c1b
commit af612f47d1
2 changed files with 4 additions and 0 deletions

View File

@ -51,6 +51,7 @@ class BaseInflector
'/us$/i' => 'uses', '/us$/i' => 'uses',
'/(alias)$/i' => '\1es', '/(alias)$/i' => '\1es',
'/(ax|cris|test)is$/i' => '\1es', '/(ax|cris|test)is$/i' => '\1es',
'/(currenc)y$/' => '\1ies',
'/s$/' => 's', '/s$/' => 's',
'/^$/' => '', '/^$/' => '',
'/$/' => 's', '/$/' => 's',
@ -97,6 +98,7 @@ class BaseInflector
'/(n)ews$/i' => '\1\2ews', '/(n)ews$/i' => '\1\2ews',
'/(n)etherlands$/i' => '\1\2etherlands', '/(n)etherlands$/i' => '\1\2etherlands',
'/eaus$/' => 'eau', '/eaus$/' => 'eau',
'/(currenc)ies$/' => '\1y',
'/^(.*us)$/' => '\\1', '/^(.*us)$/' => '\\1',
'/s$/i' => '', '/s$/i' => '',
]; ];

View File

@ -31,6 +31,7 @@ class InflectorTest extends TestCase
'test' => 'tests', 'test' => 'tests',
'car' => 'cars', 'car' => 'cars',
'netherlands' => 'netherlands', 'netherlands' => 'netherlands',
'currency' => 'currencies',
]; ];
foreach ($testData as $testIn => $testOut) { foreach ($testData as $testIn => $testOut) {
@ -59,6 +60,7 @@ class InflectorTest extends TestCase
'tests' => 'test', 'tests' => 'test',
'cars' => 'car', 'cars' => 'car',
'Netherlands' => 'Netherlands', 'Netherlands' => 'Netherlands',
'currencies' => 'currency',
]; ];
foreach ($testData as $testIn => $testOut) { foreach ($testData as $testIn => $testOut) {
$this->assertEquals($testOut, Inflector::singularize($testIn)); $this->assertEquals($testOut, Inflector::singularize($testIn));