lib: Add separator parameter to String::cname()

This commit is contained in:
Eric Lippmann 2014-12-18 17:23:54 +01:00
parent 4dfac28393
commit 1468ed0a19
1 changed files with 4 additions and 3 deletions

View File

@ -23,16 +23,17 @@ class String
}
/**
* Uppercase the first character of each word in a string assuming and removing the underscore as word separator
* Uppercase the first character of each word in a string
*
* Converts 'first_name' to 'firstName' for example.
*
* @param string $name
* @param string $separator Word separator
*
* @return string
*/
public static function cname($name)
public static function cname($name, $separator = '_')
{
return str_replace(' ', '', ucwords(str_replace('_', ' ', strtolower($name))));
return str_replace(' ', '', ucwords(str_replace($separator, ' ', strtolower($name))));
}
}