lib: Add separator parameter to String::cname()
This commit is contained in:
parent
4dfac28393
commit
1468ed0a19
|
@ -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))));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue