From 1634eefce58fbf53b4837bfc6f67dac4010c322f Mon Sep 17 00:00:00 2001 From: phpnut Date: Tue, 31 Oct 2006 03:14:26 +0000 Subject: [PATCH] Adding Inflector::variable() to create camelBacked version of a string git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@3766 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/libs/inflector.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cake/libs/inflector.php b/cake/libs/inflector.php index a35b5e61e..971faa13a 100644 --- a/cake/libs/inflector.php +++ b/cake/libs/inflector.php @@ -379,6 +379,18 @@ class Inflector extends Object { $replace = Inflector::camelize(Inflector::singularize($tableName)); return $replace; } +/** + * Returns camelBacked version of a string. + * + * @param string $string + * @return string + */ + function variable($string) { + $string = Inflector::camelize(Inflector::underscore($string)); + $replace = strtolower(substr($string, 0, 1)); + $variable = preg_replace('/\\w/', $replace, $string, 1); + return $variable; + } } /**