From afc80dd4d1710d1c4481fad87c6e9c1ddf7adb8e Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Mon, 8 Aug 2011 10:42:24 -0500 Subject: [PATCH] Refactor the inflector class. --- system/inflector.php | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/system/inflector.php b/system/inflector.php index 3b145a2a..d7d9ef19 100644 --- a/system/inflector.php +++ b/system/inflector.php @@ -121,9 +121,15 @@ class Inflector { */ public static function plural($value) { - if (array_key_exists($value, static::$plural_cache)) return static::$plural_cache[$value]; + if (array_key_exists($value, static::$plural_cache)) + { + return static::$plural_cache[$value]; + } - if (in_array(strtolower($value), static::$uncountable)) return static::$plural_cache[$value] = $value; + if (in_array(strtolower($value), static::$uncountable)) + { + return static::$plural_cache[$value] = $value; + } foreach (static::$irregular as $pattern => $irregular) { @@ -154,9 +160,15 @@ class Inflector { */ public static function singular($value) { - if (array_key_exists($value, static::$singular_cache)) return static::$singular_cache[$value]; + if (array_key_exists($value, static::$singular_cache)) + { + return static::$singular_cache[$value]; + } - if (in_array(strtolower($value), static::$uncountable)) return static::$singular_cache[$value] = $value; + if (in_array(strtolower($value), static::$uncountable)) + { + return static::$singular_cache[$value] = $value; + } foreach (static::$irregular as $irregular => $pattern) {