From 12fe58d997d2066dc362fd393a18b4e5da190513 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Wed, 27 May 2009 15:11:53 -0700 Subject: Rename 'kohana' to 'system' to conform to the Kohana filesystem layout. I'm comfortable with us not clearly drawing the distinction about the fact that it's Kohana. --- kohana/helpers/inflector.php | 193 ------------------------------------------- 1 file changed, 193 deletions(-) delete mode 100644 kohana/helpers/inflector.php (limited to 'kohana/helpers/inflector.php') diff --git a/kohana/helpers/inflector.php b/kohana/helpers/inflector.php deleted file mode 100644 index 1e4fee23..00000000 --- a/kohana/helpers/inflector.php +++ /dev/null @@ -1,193 +0,0 @@ - 1) - return $str; - - // Cache key name - $key = 'singular_'.$str.$count; - - if (isset(inflector::$cache[$key])) - return inflector::$cache[$key]; - - if (inflector::uncountable($str)) - return inflector::$cache[$key] = $str; - - if (empty(inflector::$irregular)) - { - // Cache irregular words - inflector::$irregular = Kohana::config('inflector.irregular'); - } - - if ($irregular = array_search($str, inflector::$irregular)) - { - $str = $irregular; - } - elseif (preg_match('/[sxz]es$/', $str) OR preg_match('/[^aeioudgkprt]hes$/', $str)) - { - // Remove "es" - $str = substr($str, 0, -2); - } - elseif (preg_match('/[^aeiou]ies$/', $str)) - { - $str = substr($str, 0, -3).'y'; - } - elseif (substr($str, -1) === 's' AND substr($str, -2) !== 'ss') - { - $str = substr($str, 0, -1); - } - - return inflector::$cache[$key] = $str; - } - - /** - * Makes a singular word plural. - * - * @param string word to pluralize - * @return string - */ - public static function plural($str, $count = NULL) - { - // Remove garbage - $str = strtolower(trim($str)); - - if (is_string($count)) - { - // Convert to integer when using a digit string - $count = (int) $count; - } - - // Do nothing with singular - if ($count === 1) - return $str; - - // Cache key name - $key = 'plural_'.$str.$count; - - if (isset(inflector::$cache[$key])) - return inflector::$cache[$key]; - - if (inflector::uncountable($str)) - return inflector::$cache[$key] = $str; - - if (empty(inflector::$irregular)) - { - // Cache irregular words - inflector::$irregular = Kohana::config('inflector.irregular'); - } - - if (isset(inflector::$irregular[$str])) - { - $str = inflector::$irregular[$str]; - } - elseif (preg_match('/[sxz]$/', $str) OR preg_match('/[^aeioudgkprt]h$/', $str)) - { - $str .= 'es'; - } - elseif (preg_match('/[^aeiou]y$/', $str)) - { - // Change "y" to "ies" - $str = substr_replace($str, 'ies', -1); - } - else - { - $str .= 's'; - } - - // Set the cache and return - return inflector::$cache[$key] = $str; - } - - /** - * Makes a phrase camel case. - * - * @param string phrase to camelize - * @return string - */ - public static function camelize($str) - { - $str = 'x'.strtolower(trim($str)); - $str = ucwords(preg_replace('/[\s_]+/', ' ', $str)); - - return substr(str_replace(' ', '', $str), 1); - } - - /** - * Makes a phrase underscored instead of spaced. - * - * @param string phrase to underscore - * @return string - */ - public static function underscore($str) - { - return preg_replace('/\s+/', '_', trim($str)); - } - - /** - * Makes an underscored or dashed phrase human-reable. - * - * @param string phrase to make human-reable - * @return string - */ - public static function humanize($str) - { - return preg_replace('/[_-]+/', ' ', trim($str)); - } - -} // End inflector \ No newline at end of file -- cgit v1.2.3