summaryrefslogtreecommitdiffstats
path: root/system/helpers/inflector_helper.php
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-01-07 00:18:33 +0100
committerAndrey Andreev <narf@bofh.bg>2012-01-07 00:18:33 +0100
commitd350d13446faf41d6c0301d34760ba475efd7f49 (patch)
treea9dc48c0b919e9f86a3ad8cc1c26d40102d16e47 /system/helpers/inflector_helper.php
parent7fd137b9cb3aa8477e92ecce434ac61e904527c2 (diff)
parent9252d7bf2208d351aad4292cb79c509391f0313f (diff)
Merge upstream branch
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 */