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.php30
1 files changed, 5 insertions, 25 deletions
diff --git a/system/helpers/inflector_helper.php b/system/helpers/inflector_helper.php
index f093dd921..0bd1e112f 100644
--- a/system/helpers/inflector_helper.php
+++ b/system/helpers/inflector_helper.php
@@ -1,4 +1,4 @@
-<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
@@ -85,16 +85,7 @@ if ( ! function_exists('singular'))
'/([^u])s$/' => '\1',
);
- foreach ($singular_rules as $rule => $replacement)
- {
- if (preg_match($rule, $result))
- {
- $result = preg_replace($rule, $replacement, $result);
- break;
- }
- }
-
- return $result;
+ return preg_replace(array_keys($singular_values), $singular_values, $result);
}
}
@@ -138,16 +129,7 @@ if ( ! function_exists('plural'))
'/$/' => 's',
);
- foreach ($plural_rules as $rule => $replacement)
- {
- if (preg_match($rule, $result))
- {
- $result = preg_replace($rule, $replacement, $result);
- break;
- }
- }
-
- return $result;
+ return preg_replace(array_keys($plural_rules), $plural_rules, $result);
}
}
@@ -166,9 +148,7 @@ if ( ! function_exists('camelize'))
{
function camelize($str)
{
- $str = 'x'.strtolower(trim($str));
- $str = ucwords(preg_replace('/[\s_]+/', ' ', $str));
- return substr(str_replace(' ', '', $str), 1);
+ return substr(str_replace(' ', '', ucwords(preg_replace('/[\s_]+/', ' ', $str))), 1);
}
}
@@ -212,4 +192,4 @@ if ( ! function_exists('humanize'))
}
/* End of file inflector_helper.php */
-/* Location: ./system/helpers/inflector_helper.php */ \ No newline at end of file
+/* Location: ./system/helpers/inflector_helper.php */