From 1468ed0a1979574ff20d859cd7f4f6128b93d2b2 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 18 Dec 2014 17:23:54 +0100 Subject: [PATCH] lib: Add separator parameter to String::cname() --- library/Icinga/Util/String.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/library/Icinga/Util/String.php b/library/Icinga/Util/String.php index 0bebb06e7..248ab0d34 100644 --- a/library/Icinga/Util/String.php +++ b/library/Icinga/Util/String.php @@ -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)))); } }