summaryrefslogtreecommitdiffstats
path: root/system/helpers/inflector_helper.php
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-01-06 18:09:22 +0100
committerAndrey Andreev <narf@bofh.bg>2012-01-06 18:09:22 +0100
commit1e6b72cca80354619cf7ddceb2b5f23d37b972e9 (patch)
tree57613f7986517d22504bf637ff1c8ce4d78812fd /system/helpers/inflector_helper.php
parent20b4fa2fc12d0630aa8c5d9ce09623e58d98f9ca (diff)
Improve html, inflector & language helpers
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 */