summaryrefslogtreecommitdiffstats
path: root/system/helpers/inflector_helper.php
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@server-speed.net>2011-01-28 22:51:06 +0100
committerFlorian Pritz <bluewind@server-speed.net>2011-01-28 22:58:52 +0100
commitce2b69675075444c9e40b72bcdd42ab7edbbe633 (patch)
tree2932f13b0db14fe53dc0622d888318db638a017f /system/helpers/inflector_helper.php
parentb6b8a6587c399bfd89e13e92ce04ee8486688e6e (diff)
update to CI 2.0
Signed-off-by: Florian Pritz <bluewind@server-speed.net>
Diffstat (limited to 'system/helpers/inflector_helper.php')
-rwxr-xr-x[-rw-r--r--]system/helpers/inflector_helper.php43
1 files changed, 27 insertions, 16 deletions
diff --git a/system/helpers/inflector_helper.php b/system/helpers/inflector_helper.php
index ffa99cc26..4cd7486b4 100644..100755
--- a/system/helpers/inflector_helper.php
+++ b/system/helpers/inflector_helper.php
@@ -2,11 +2,11 @@
/**
* CodeIgniter
*
- * An open source application development framework for PHP 4.3.2 or newer
+ * An open source application development framework for PHP 5.1.6 or newer
*
* @package CodeIgniter
* @author ExpressionEngine Dev Team
- * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc.
+ * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 1.0
@@ -36,14 +36,14 @@
* @access public
* @param string
* @return str
- */
+ */
if ( ! function_exists('singular'))
-{
+{
function singular($str)
{
$str = strtolower(trim($str));
$end = substr($str, -3);
-
+
if ($end == 'ies')
{
$str = substr($str, 0, strlen($str)-3).'y';
@@ -55,13 +55,13 @@ if ( ! function_exists('singular'))
else
{
$end = substr($str, -1);
-
+
if ($end == 's')
{
$str = substr($str, 0, strlen($str)-1);
}
}
-
+
return $str;
}
}
@@ -77,9 +77,9 @@ if ( ! function_exists('singular'))
* @param string
* @param bool
* @return str
- */
+ */
if ( ! function_exists('plural'))
-{
+{
function plural($str, $force = FALSE)
{
$str = strtolower(trim($str));
@@ -91,6 +91,17 @@ if ( ! function_exists('plural'))
$vowels = array('a', 'e', 'i', 'o', 'u');
$str = in_array(substr($str, -2, 1), $vowels) ? $str.'s' : substr($str, 0, -1).'ies';
}
+ elseif ($end == 'h')
+ {
+ if (substr($str, -2) == 'ch' OR substr($str, -2) == 'sh')
+ {
+ $str .= 'es';
+ }
+ else
+ {
+ $str .= 's';
+ }
+ }
elseif ($end == 's')
{
if ($force == TRUE)
@@ -117,11 +128,11 @@ if ( ! function_exists('plural'))
* @access public
* @param string
* @return str
- */
+ */
if ( ! function_exists('camelize'))
-{
+{
function camelize($str)
- {
+ {
$str = 'x'.strtolower(trim($str));
$str = ucwords(preg_replace('/[\s_]+/', ' ', $str));
return substr(str_replace(' ', '', $str), 1);
@@ -138,7 +149,7 @@ if ( ! function_exists('camelize'))
* @access public
* @param string
* @return str
- */
+ */
if ( ! function_exists('underscore'))
{
function underscore($str)
@@ -157,15 +168,15 @@ if ( ! function_exists('underscore'))
* @access public
* @param string
* @return str
- */
+ */
if ( ! function_exists('humanize'))
-{
+{
function humanize($str)
{
return ucwords(preg_replace('/[_]+/', ' ', strtolower(trim($str))));
}
}
-
+
/* End of file inflector_helper.php */
/* Location: ./system/helpers/inflector_helper.php */ \ No newline at end of file