summaryrefslogtreecommitdiffstats
path: root/system/helpers/inflector_helper.php
diff options
context:
space:
mode:
Diffstat (limited to 'system/helpers/inflector_helper.php')
-rw-r--r--system/helpers/inflector_helper.php133
1 files changed, 73 insertions, 60 deletions
diff --git a/system/helpers/inflector_helper.php b/system/helpers/inflector_helper.php
index b1864cb0b..bf70a6799 100644
--- a/system/helpers/inflector_helper.php
+++ b/system/helpers/inflector_helper.php
@@ -36,34 +36,36 @@
* @access public
* @param string
* @return str
- */
-function singular($str)
-{
- $str = strtolower(trim($str));
- $end = substr($str, -3);
+ */
+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';
- }
- elseif ($end == 'ses')
- {
- $str = substr($str, 0, strlen($str)-2);
- }
- else
- {
- $end = substr($str, -1);
+ if ($end == 'ies')
+ {
+ $str = substr($str, 0, strlen($str)-3).'y';
+ }
+ elseif ($end == 'ses')
+ {
+ $str = substr($str, 0, strlen($str)-2);
+ }
+ else
+ {
+ $end = substr($str, -1);
- if ($end == 's')
- {
- $str = substr($str, 0, strlen($str)-1);
- }
- }
+ if ($end == 's')
+ {
+ $str = substr($str, 0, strlen($str)-1);
+ }
+ }
- return $str;
+ return $str;
+ }
}
-
// --------------------------------------------------------------------
/**
@@ -75,32 +77,34 @@ function singular($str)
* @param string
* @param bool
* @return str
- */
-function plural($str, $force = FALSE)
-{
- $str = strtolower(trim($str));
- $end = substr($str, -1);
-
- if ($end == 'y')
- {
- $str = substr($str, 0, strlen($str)-1).'ies';
- }
- elseif ($end == 's')
- {
- if ($force == TRUE)
- {
- $str .= 'es';
- }
- }
- else
- {
- $str .= 's';
- }
-
- return $str;
+ */
+if (! function_exists('plural'))
+{
+ function plural($str, $force = FALSE)
+ {
+ $str = strtolower(trim($str));
+ $end = substr($str, -1);
+
+ if ($end == 'y')
+ {
+ $str = substr($str, 0, strlen($str)-1).'ies';
+ }
+ elseif ($end == 's')
+ {
+ if ($force == TRUE)
+ {
+ $str .= 'es';
+ }
+ }
+ else
+ {
+ $str .= 's';
+ }
+
+ return $str;
+ }
}
-
// --------------------------------------------------------------------
/**
@@ -111,12 +115,15 @@ function plural($str, $force = FALSE)
* @access public
* @param string
* @return str
- */
-function camelize($str)
-{
- $str = 'x'.strtolower(trim($str));
- $str = ucwords(preg_replace('/[\s_]+/', ' ', $str));
- return substr(str_replace(' ', '', $str), 1);
+ */
+if (! function_exists('camelize'))
+{
+ function camelize($str)
+ {
+ $str = 'x'.strtolower(trim($str));
+ $str = ucwords(preg_replace('/[\s_]+/', ' ', $str));
+ return substr(str_replace(' ', '', $str), 1);
+ }
}
// --------------------------------------------------------------------
@@ -129,10 +136,13 @@ function camelize($str)
* @access public
* @param string
* @return str
- */
-function underscore($str)
+ */
+if (! function_exists('underscore'))
{
- return preg_replace('/[\s]+/', '_', strtolower(trim($str)));
+ function underscore($str)
+ {
+ return preg_replace('/[\s]+/', '_', strtolower(trim($str)));
+ }
}
// --------------------------------------------------------------------
@@ -145,10 +155,13 @@ function underscore($str)
* @access public
* @param string
* @return str
- */
-function humanize($str)
-{
- return ucwords(preg_replace('/[_]+/', ' ', strtolower(trim($str))));
+ */
+if (! function_exists('humanize'))
+{
+ function humanize($str)
+ {
+ return ucwords(preg_replace('/[_]+/', ' ', strtolower(trim($str))));
+ }
}
?> \ No newline at end of file