2014-02-12 17:01:11 +01:00
|
|
|
<?php
|
|
|
|
// {{{ICINGA_LICENSE_HEADER}}}
|
|
|
|
// {{{ICINGA_LICENSE_HEADER}}}
|
|
|
|
|
|
|
|
namespace Icinga\Util;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Common string helper
|
|
|
|
*/
|
|
|
|
class String
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Split string into an array and trim spaces
|
|
|
|
*
|
|
|
|
* @param string $value
|
|
|
|
* @param string $delimiter
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public static function trimSplit($value, $delimiter = ',')
|
|
|
|
{
|
2014-03-03 18:16:07 +01:00
|
|
|
return array_map('trim', explode($delimiter, $value));
|
2014-02-12 17:01:11 +01:00
|
|
|
}
|
2014-09-30 22:34:58 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Uppercase the first character of each word in a string assuming and removing the underscore as word separator
|
|
|
|
*
|
|
|
|
* Converts 'first_name' to 'firstName' for example.
|
|
|
|
*
|
|
|
|
* @param string $name
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public static function cname($name)
|
|
|
|
{
|
|
|
|
return str_replace(' ', '', ucwords(str_replace('_', ' ', strtolower($name))));
|
|
|
|
}
|
2014-02-12 17:01:11 +01:00
|
|
|
}
|