Transform a string by a certain method.
$string: The input you want to transform.
$option: How do you want to transform it, possible values:
string The transformed string.
protected function caseTransform($string, $option) {
switch ($option) {
default:
return $string;
case 'upper':
return drupal_strtoupper($string);
case 'lower':
return drupal_strtolower($string);
case 'ucfirst':
return drupal_strtoupper(drupal_substr($string, 0, 1)) . drupal_substr($string, 1);
case 'ucwords':
if (Unicode::getStatus() == Unicode::STATUS_MULTIBYTE) {
return mb_convert_case($string, MB_CASE_TITLE);
}
else {
return ucwords($string);
}
}
}