Refactoring the inflector.
This commit is contained in:
parent
5862faf2c4
commit
2e482d31e4
|
@ -121,15 +121,9 @@ class Inflector {
|
||||||
*/
|
*/
|
||||||
public static function plural($value)
|
public static function plural($value)
|
||||||
{
|
{
|
||||||
if (array_key_exists($value, static::$plural_cache))
|
if (array_key_exists($value, static::$plural_cache)) return static::$plural_cache[$value];
|
||||||
{
|
|
||||||
return static::$plural_cache[$value];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(strtolower($value), static::$uncountable))
|
if (in_array(strtolower($value), static::$uncountable)) return static::$plural_cache[$value] = $value;
|
||||||
{
|
|
||||||
return static::$plural_cache[$value] = $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (static::$irregular as $pattern => $irregular)
|
foreach (static::$irregular as $pattern => $irregular)
|
||||||
{
|
{
|
||||||
|
@ -160,15 +154,9 @@ public static function plural($value)
|
||||||
*/
|
*/
|
||||||
public static function singular($value)
|
public static function singular($value)
|
||||||
{
|
{
|
||||||
if (array_key_exists($value, static::$singular_cache))
|
if (array_key_exists($value, static::$singular_cache)) return static::$singular_cache[$value];
|
||||||
{
|
|
||||||
return static::$singular_cache[$value];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (in_array(strtolower($value), static::$uncountable))
|
if (in_array(strtolower($value), static::$uncountable)) return static::$singular_cache[$value] = $value;
|
||||||
{
|
|
||||||
return static::$singular_cache[$value] = $value;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (static::$irregular as $irregular => $pattern)
|
foreach (static::$irregular as $irregular => $pattern)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue