Main function for NameCase.

@param string $string
@param array  $options

@return string
423700
public static function nameCase($string = '', array $options = [])
    {
        if ($string == '') return $string;

        self::$options = array_merge(self::$options, $options);

        // Do not do anything if string is mixed and lazy option is true.
        if (self::$options['lazy'] && self::skipMixed($string)) return $string;

        // Capitalize
        $string = self::capitalize($string);
        $string = self::updateIrish($string);

        // Fixes for "son (daughter) of" etc
        foreach (self::$replacements as $pattern => $replacement) {
            $string = mb_ereg_replace($pattern, $replacement, $string);
        }

        $string = self::updateRoman($string);
        $string = self::fixConjunction($string);

        return $string;
    }
403194
function(string, options) {
      options = options || {};
      var separator = options.separator || '_';
      var split = options.split || /(?=[A-Z])/;

      return string.split(split).join(separator);
    }
606991
public static function uppercase($string = false, $selector = false) {

        if ($string) {

            switch ($selector) {
                case 'first':
                    return ucfirst($string);
                case 'words':
                    return ucwords($string);
                default:
                    return strtoupper($string);
            }
        }

        return false;
    }
378939
public static function makeByString($string)
    {
        $fg = $bg = '';
        $extra = false;
        $options = [];
        $parts = \explode(';', \str_replace(' ', '', $string));

        foreach ($parts as $part) {
            $subParts = \explode('=', $part);

            if (\count($subParts) < 2) {
                continue;
            }

            switch ($subParts[0]) {
                case 'fg':
                    $fg = $subParts[1];
                    break;
                case 'bg':
                    $bg = $subParts[1];
                    break;
                case 'extra':
                    $extra = (bool)$subParts[1];
                    break;
                case 'options':
                    $options = \explode(',', $subParts[1]);
                    break;
                default:
                    throw new \RuntimeException('Invalid option');
                    break;
            }
        }

        return new self($fg, $bg, $options, $extra);
    }
292358
public static function validatePascalCase($string)
    {
        if (SetupHelper::getPascalCase($string) === $string) {
            return (string)$string;
        }

        throw new InvalidArgumentException(
            sprintf(
                'Provided string "%1$s" was not in PascalCase.',
                $string
            )
        );
    }
199183
private function mkstr($name, $type = 'string', $options = array())
    {
        $result = "  define('$name', ";
        $quot = "'";
        $value = isset($_POST[$name]) ? $_POST[$name] : null;

        if (isset($options['nobr']) && $options['nobr'])
        {
            $value = str_replace(array("\n", "\r"), ' ', $value);
        }

        if (isset($options['savebr']) && $options['savebr'])
        {
            $value = addcslashes($value, "\n\r\"");
            $quot = '"';
        }

        switch ($type)
        {
            case 'string':
                $value = str_replace(
                    array('\\', $quot),
                    array('\\\\', '\\' . $quot),
                    $value
                );
                $value = $quot . $value . $quot;
                break;
            case 'bool':
                $value = $value ? 'true' : 'false';
                break;
            case 'int':
                $value = intval($value);
                break;
        }
        $result .= $value . ");\n";
        return $result;
    }
653564
public static function normalCase($string) {
        return static::cache(array(__METHOD__, $string), function() use ($string) {
            return ucfirst(mb_strtolower(str_replace('_', ' ', $string)));
        });
    }
146471
public static function toCase($string, $case)
    {
        switch ($case) {
            case self::UPPER:
                $string = mb_strtoupper($string);
                break;
            case self::LOWER:
                $string = mb_strtolower($string);
                break;
            case self::UPPER_FIRST:
                $string = mb_strtoupper(mb_substr($string, 0, 1)) . mb_substr($string, 1);
                break;
            case self::UPPER_WORDS:
                $string = mb_convert_case($string, MB_CASE_TITLE);
                break;
            case self::NONE:
                break;
            default:
                throw new InvalidArgumentException("Cannot set case {$case}");
        }

        return $string;
    }
491848
public function renderStringTemplate(string $string, array $parameters = []): string
    {
        try {
            $parameters = iterator_to_array($this->getTemplateVariables($parameters));

            $environment = new Environment(new ArrayLoader());
            $template = $environment->createTemplate($string);

            return $environment->resolveTemplate($template)->render($parameters);
        } catch (Throwable $t) {
            return '';
        }
    }
277161
protected function changeCase($string)
    {
        if ($this->isLowercase()) {
            return strtolower($string);
        }

        if ($this->isUppercase()) {
            return strtoupper($string);
        }

        return $string;
    }
1107214
public static function underscoresToCamelCase($string, $capitalizeFirstChar = false)
    {
        $str = str_replace(' ', '', ucwords(str_replace('_', ' ', $string)));
        if (!empty($str) && !$capitalizeFirstChar) {
            $str[0] = strtolower($str[0]);
        }

        return $str;
    }
863480
public static function tableName($string) {
        return static::cache(array(__METHOD__, $string), function() use ($string) {
            return lcfirst(Inflector::camelCase(Inflector::pluralize($string)));
        });
    }
687600
public static function camelCase(string $string, array $noStrip = null, bool $lowerCaseFirstLetter = null)
    {
        // non-alpha and non-numeric characters become spaces
        $string = preg_replace('/[^a-z0-9' . implode('', $noStrip ?? []) . ']+/i', ' ', $string);
        $string = trim($string);
        $string = ucwords($string);
        $string = str_replace(' ', '', $string);

        if ($lowerCaseFirstLetter === null || $lowerCaseFirstLetter === true) {
            $string = lcfirst($string);
        }

        return $string;
    }
1042895
public function get_formatted_name($options = array()) {
        if ($this->id) {
            $context = $this->get_context();
            return format_string($this->name, true, array('context' => $context) + $options);
        } else {
            return get_string('top');
        }
    }
792696
function uppercaseFirstLetter(options) {
  const string = options.fn(this);
  return string.charAt(0).toUpperCase() + string.slice(1);
}
1176522
public function addNamespace($string)
    {
        if (is_array($string)) {
            foreach ($string as &$str) {
                $str = $this->addNamespace($str);
            }

            return $string;
        }

        if (strpos($string, $this->namespace) !== 0) {
            $string = $this->namespace . $string;
        }

        return $string;
    }
802328
public static function toPascalCase(string $string): string
    {
        $words = self::_prepStringForCasing($string);
        $string = implode('', array_map([
            static::class,
            'upperCaseFirst'
        ], $words));

        return $string;
    }