icingaweb2/library/Icinga/Util/String.php

39 lines
851 B
PHP
Raw Normal View History

<?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));
}
/**
* 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))));
}
}