Convert underscored or whitespace separated words into sentence case.

@param string $text

@return string
356456
private static function inflect($text)
    {
        $words = \trim(\preg_replace('/[\s_-]+/', ' ', \preg_replace('/([a-z])([A-Z])/', '$1 $2', $text)));

        return \implode(' ', \array_map('ucfirst', \explode(' ', $words)));
    }
770588
public static function strtotitle($text) {
        if (empty($text)) {
            return $text;
        }

        if (function_exists('mb_convert_case')) {
            return mb_convert_case($text, MB_CASE_TITLE, 'UTF-8');
        }

        $text = self::strtolower($text);
        $words = explode(' ', $text);
        foreach ($words as $i=>$word) {
            $length = self::strlen($word);
            if (!$length) {
                continue;

            } else if ($length == 1) {
                $words[$i] = self::strtoupper($word);

            } else {
                $letter = self::substr($word, 0, 1);
                $letter = self::strtoupper($letter);
                $rest   = self::substr($word, 1);
                $words[$i] = $letter.$rest;
            }
        }
        return implode(' ', $words);
    }
313432
public static function strip(string $text): string
    {
        if (false === \strpos($text, '</')) {
            return $text;
        }

        // $text = \strip_tags($text);
        return \preg_replace(self::STRIP_TAG, '', $text);
    }
720083
public function format($text)
    {
        $lines = explode("\n", $text);
        foreach ($lines as &$line) {
            $line = ($this->quote) . str_repeat(' ', $this->indent) . $line;
        }
        return Colour::colour(implode("\n", $lines), $this->foregroundColors, $this->backgroundColors);
    }
1191300
public function quote($text)
    {
        if ($con = $this->getConnection()) {
            return $con->quote($text);
        } else {
            return "'" . $this->disconnectedEscapeText($text) . "'";
        }
    }
623520
public function clean($text)
    {
        if (!$this->handler) {
            return $text;
        }

        $handler = $this->handler;

        return $handler($text);
    }
503447
public function split($text)
    {
        $this->probabilityCalculator->setAbbreviations($this->getAbbreviations());

        $tokens = $this->lexer->run($text);
        $probabilities = $this->probabilityCalculator->calculate($tokens);
        $sentences = $this->sentenceBuilder->build($probabilities);

        return $sentences;
    }
701717
private static function sortData($text)
    {
        if (preg_match('/[-,\\n]/', $text)) {
            $broken = preg_split('/[-,\\n]/', $text);
            for ($i = 0; $i < strlen($broken[0]); $i++) {
                if (is_numeric(substr($broken[0], $i, 1))) {
                    return array(
                        substr($broken[0], 0, $i),
                        substr($broken[0], $i),
                        $broken[1]
                    );
                }
            }
        }
        $text = preg_replace('/\s/', ' ', $text);
        $find = substr($text, -strlen($text));
        for ($i  =0; $i < strlen($text); $i++) {
            if (is_numeric(substr($find, $i, 1))) {
                return array(
                    substr($text, 0, -strlen($text)+$i),
                    substr($text, -strlen($text)+$i),
                    ''
                );
            }
        }
        return array($text, '', '');
    }
81941
public static function cleanText($text): string
    {
        return html_entity_decode(self::oneSpace(str_replace(' ?', '', mb_convert_encoding(strip_tags($text), 'UTF-8', 'UTF-8'))));
    }
676297
protected function cleanText($text)
    {
        $strippedText = strip_tags($text);
        $strippedText = htmlentities($strippedText, ENT_QUOTES, $this->getCharset(), FALSE);
        return html_entity_decode($strippedText, ENT_QUOTES, $this->getCharset());
    }
253301
public function text( string $text ): string
	{
		$then = $this->getThen();
		if( $this->lang_text )
		{
			return $this->lang->text($text, $then);
		}
		else
		{
			return $text;
		}
	}
847674
static public function getAllSubStrings($text)
    {
        $splitText = str_split($text);
        $splitCount = count($splitText);
        $subStrings = [];
        for ($i = 0; $i < $splitCount; $i++)
        {
            for ($j = $i; $j < $splitCount; $j++)
            {
                $subStrings[] = implode(array_slice($splitText, $i, $j - $i + 1));
            }
        }
        return $subStrings;
    }
929769
public function filterCamelCaseToDash($text)
    {
        $text = StaticFilter::execute($text, 'Word\CamelCaseToDash');
        $text = StaticFilter::execute($text, 'StringToLower');

        return $text;
    }
44703
public static function undent($text)
	{
		preg_match('/^\s+/', $text, $matches);
		list ($indent) = $matches;
		if ($indent)
		{
			$text = preg_replace("/^$indent/m", '', $text);
		}
		return $text;
	}
1094778
private function sanitizeText(string $text): string
    {
        $text = preg_replace($this->isMultiLine() ? '/[\x00-\x09\x0B\x0C\x0E-\x1F\x7F]/u' : '/[\x00-\x1F\x7F]/u', '', $text);

        return $text;
    }
1131200
public function prompt($text) {

        // send out any escaping to implement anything sitting in the desired state
        $this->outputEscapeSequence();

        // save off the prompt string
        $prompt = $text  . $this->promptCaret . " ";

        // prompt and return the answer
        return $this->readUserInput($prompt);

    }
723485
public static function humanize(string $text): string
    {
        $text = \str_replace(['-', '_'], ' ', $text);

        return Stringy::create($text)->humanize()->titleize();
    }