mirror of
https://github.com/Icinga/icingaweb2.git
synced 2026-06-11 09:31:31 -04:00
lib: Add separator parameter to String::cname()
This commit is contained in:
parent
4dfac28393
commit
1468ed0a19
1 changed files with 4 additions and 3 deletions
|
|
@ -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 a new issue