Create a sensible, human readable default for $string,
e.g. creating a label for the name of form inputs.

@param string $string the string to transform
519839
protected function sensible($string)
    {
        $string = preg_replace('`([A-Z])`', '-\1', $string);
        $string = str_replace(array('-', '_'), ' ', $string);

        return ucfirst(trim(strtolower($string)));
    }
808197
private function prepareString($string)
    {
        return str_replace(
            array_keys($this->owner->variables),
            array_values($this->owner->variables),
            $string
        );
    }
1075240
public function apply(string $string) : string
    {
        return str_replace($this->search, $this->replace, $string);
    }
83155
protected function fixCharset($string)
    {
        if ('UTF-8' !== $this->getCharset()) {
            $string = mb_convert_encoding($string, $this->getCharset(), 'UTF-8');
        }

        return $string;
    }
244841
protected function boldLn(string $string)
    {
        $this->bold($string);
        $this->output->writeln('');

        return $this;
    }
1183324
public static function ucfirst($string)
    {
        switch (static::strlen($string)) {
            case 0:
                return '';
            case 1:
                return static::strtoupper($string);
            default:
                return static::strtoupper(static::substr($string, 0, 1)) . static::substr($string, 1);
        }
    }
1321222
private function parseResponseHeaders($string) {
        $parts = explode("\n", $string);
        foreach ($parts as $part) {
            if (strpos($part, ':') !== false) {
                list($name, $value) = explode(':', $part);
                $this->responseHeaders[trim($name)] = trim($value);
            }
        }
    }
1144168
public void setString(String string)
    {
        m_StaticString = string;
        if (this.getScreenFieldView().getControl() != null)
            this.getScreenFieldView().setComponentState(this.getScreenFieldView().getControl(), string);
    }
618379
static function fromString(string $string): self
    {
        $string = str_replace("/", "\\", $string);
        $string = preg_replace("#(\\\\){2,}#", "\\", $string);
        if (substr($string, -1, 1) == "\\") {
            $string = substr($string, 0, -1);
        }
        
        return new self($string);
    }
1069534
public function warn($string)
    {
        $style = new OutputFormatterStyle('yellow');

        $this->output->getFormatter()->setStyle('warning', $style);

        $this->output->writeln("<warning>$string</warning>");
    }
1340796
protected function _formatString($string)
    {
        $quote = substr($string, 0, 1);
        $string = substr($string, 1, -1);
        if ($quote === '"') {
            $string = stripcslashes($string);
        } else {
            $string = strtr($string, ["\\'" => "'", '\\\\' => '\\']);
        }
        $string = str_replace("\r\n", "\n", $string);

        return addcslashes($string, "\0..\37\\\"");
    }
414678
public function prepare(string $string): string
    {
        foreach ($this->_steps as $step) {
            $string = $step->apply($string);
        }
        return $string;
    }
1192622
private function createStyleFromString($string) {
        if (isset($this->styles[$string])) {
            return $this->styles[$string];
        }

        if (!preg_match_all('/([^=]+)=([^;]+)(;|$)/', strtolower($string), $matches, PREG_SET_ORDER)) {
            return false;
        }

        $style = new Style();
        foreach ($matches as $match) {
            array_shift($match);

            if ('fg' == $match[0]) {
                $style->setForeground($match[1]);
            }
            elseif ('bg' == $match[0]) {
                $style->setBackground($match[1]);
            }
            else {
                try {
                    $style->setOption($match[1]);
                }
                catch (\InvalidArgumentException $e) {
                    return false;
                }
            }
        }

        return $style;
    }
491027
public static function get_string_from_input($string) {
        $string = trim($string);

        if (preg_match('|^([a-zA-Z][a-zA-Z0-9\.:/_-]*),([a-zA-Z][a-zA-Z0-9\.:/_-]*)$|', $string, $matches)) {
            if ($matches[2] === 'moodle') {
                $matches[2] = 'core';
            }

            if (get_string_manager()->string_exists($matches[1], $matches[2])) {
                $string = get_string($matches[1], $matches[2]);
            }
        }

        return $string;
    }
483704
public function format($string) {
        if ($this->isAnsiEnabled()) {
            return $this->formatAnsi($string);
        }

        return $this->formatPlain($string);
    }
336731
public function loadString($string)
    {
        $this->string = htmlspecialchars_decode($string);

        return (bool)empty($this->string);
    }
922329
public static function fromString($string)
    {
        $parts = explode(':', $string, 3);
        Assertion::count($parts, 3, 'NodeRef format must be "vendor:label:id');
        $id = array_pop($parts);
        $qname = SchemaQName::fromString(implode(':', $parts));
        return new self($qname, $id);
    }