You are here

public function TamperConvertCase::execute in Tamper 7

Executes the plugin.

Parameters

string $value: The value to transform.

Return value

string The transformed value.

Overrides TamperPluginInterface::execute

File

src/Plugins/TamperConvertCase.php, line 42
Contains TamperConvertCase.

Class

TamperConvertCase
Converts the case of a string.

Code

public function execute($value) {
  switch ($this->configuration['mode']) {
    case 'upper':
      return drupal_strtoupper($value);
    case 'lower':
      return drupal_strtolower($value);
    case 'ucfirst':
      return drupal_strtoupper(drupal_substr($value, 0, 1)) . drupal_substr($value, 1);
    case 'ucwords':
      global $multibyte;
      if ($multibyte == UNICODE_MULTIBYTE) {
        return mb_convert_case($value, MB_CASE_TITLE);
      }
      else {
        return ucwords($value);
      }
  }
}