@param string $string
@param int $spaces

@return string
965471
public function indent($string, $spaces = 2) {
        $indentation = str_repeat(' ', $spaces);
        $lines = explode("\n", $string);

        foreach ($lines as $index => $line) {
            $lines[$index] = $indentation . $line;
        }

        return implode("\n", $lines);
    }
50272
def indent_string(string, num_spaces=2):
    '''

    '''
    indent = ' '.ljust(num_spaces)
    return indent + re.sub('\n', '\n' + indent, string)
1143521
public function GetStringWidthLines($string, $lines)
    {
        $words = preg_split("/(\s+)/", $string, null, PREG_SPLIT_DELIM_CAPTURE);

        if (count($words) <= 2 || $lines <= 1) {
            return $this->GetStringWidth($string);
        }

        $min = 0;

        $widths = array();

        foreach ($words as $i => $w) {
            if ($w == "") {
                $widths[$i] = 0;
            } else {
                $widths[$i] = $this->GetStringWidth($w);
            }
        }

        $maxwidth = 0;

        for ($j = 1; $j < count($widths) && $lines > 0; $lines--) {
            if ($j > 0) {
                $wset = array_slice($widths, $j);
            } else {
                $wset = $widths;
            }
            $target = (array_sum($wset)) / $lines;

            $l = $widths[$j - 1];

            for (; $l < $target && $j < count($widths); $j += 2) {
                $l += $widths[$j] + $widths[$j + 1];
            }

            if ($j < count($widths)) {
                $cw = $widths[$j + 1];

                if ($l - $target < $target + $cw - $l) {
                    $j += 2;
                } else {
                    $l -= $cw + $widths[$j];
                }
            }

            if ($maxwidth < $l) {
                $maxwidth = $l;
            }
        }

        return $maxwidth;
    }
142157
public function toWords(string $string): string
    {
        $words = \trim(\str_replace(['-', '_'], ' ', $string));

        return \ucwords($words);
    }
1001496
public function removeNamespace($string)
    {
        $prefix = $this->namespace;

        if (substr($string, 0, strlen($prefix)) == $prefix) {
            $string = substr($string, strlen($prefix), strlen($string));
        }

        return $string;
    }
733319
static function Tokenize($string, $splitChars = ' %$§&/()?!.:;\#\'"')
    {
       $tokens = array();

       $tok = strtok($string,  $splitChars);
       while ($tok !== false)
       {
            array_push($tokens, $tok);
            $tok = strtok($splitChars);
       }
       return $tokens;
    }
712941
public static function stringUrlUnicodeSlug($string)
	{
		// Replace double byte whitespaces by single byte (East Asian languages)
		$str = preg_replace('/\xE3\x80\x80/', ' ', $string);

		// Remove any '-' from the string as they will be used as concatenator.
		// Would be great to let the spaces in but only Firefox is friendly with this

		$str = str_replace('-', ' ', $str);

		// Replace forbidden characters by whitespaces
		$str = preg_replace('#[:\#\*"@+=;!><&\.%()\]\/\'\\\\|\[]#', "\x20", $str);

		// Delete all '?'
		$str = str_replace('?', '', $str);

		// Trim white spaces at beginning and end of alias and make lowercase
		$str = trim(StringHelper::strtolower($str));

		// Remove any duplicate whitespace and replace whitespaces by hyphens
		$str = preg_replace('#\x20+#', '-', $str);

		return $str;
	}
921646
protected function strTokenWrapper($string)
    {
        $token = strtok($string, $this->tokenExpression);

        $tokens = array();
        while ($token !== false) {
            // avoid tokenizing white spaces
            if(!empty(trim($token))) { 
                $tokens[] = $token;
            }
            $token = strtok($this->tokenExpression);        
        }
        return $tokens;
    }
238721
public static function strtotitle(string $string): string
    {
        $result = '';
        $splitIntoLowerCaseWords = preg_split("/([\n\r\t ])/", self::strtolower($string), -1, PREG_SPLIT_DELIM_CAPTURE);
        foreach ($splitIntoLowerCaseWords as $delimiterOrValue) {
            $result .= self::strtoupper(self::substr($delimiterOrValue, 0, 1)) . self::substr($delimiterOrValue, 1);
        }
        return $result;
    }
1359643
function fixSpaces($spaces='')
	{
		$count = strlen($spaces);
		if($count == 0) {
			return '';
		}

		$div = floor($count / 2);
		$mod = $count % 2;
		return str_repeat('&nbsp; ', $div).str_repeat('&nbsp;', $mod);
	}
838646
public static function sgr($string, array $parameters)
    {
        $result = '';
        foreach ($parameters as $parameter) {
            $result .= sprintf("\e[%sm", $parameter);
        }
        $result .= $string . sprintf("\e[%sm", Sgr::RESET);
        return $result;
    }
1241605
public static String normaliseWhitespace(String string) {
        StringBuilder sb = StringUtil.borrowBuilder();
        appendNormalisedWhitespace(sb, string, false);
        return StringUtil.releaseBuilder(sb);
    }
712975
private function parseNamespace($tokens)
    {
        $namespace = null;
        $tokenCount = count($tokens);
        for ($offset=0; $offset < $tokenCount; $offset++) {
            if (!is_array($tokens[$offset])) {
                continue;
            }

            if (T_NAMESPACE === $tokens[$offset][0]) {
                $offset++; // the next token is a whitespace

                return $this->parseNamespaceString($tokens, $offset);
            }
        }

        return $namespace;
    }
991406
public static function stringURLUnicodeSlug($string)
	{
		// Replace double byte whitespaces by single byte (East Asian languages)
		$str = preg_replace('/\xE3\x80\x80/', ' ', $string);

		// Remove any '-' from the string as they will be used as concatenator.
		// Would be great to let the spaces in but only Firefox is friendly with this

		$str = str_replace('-', ' ', $str);

		// Replace forbidden characters by whitespaces
		$str = preg_replace('#[:\#\*"@+=;!><&\.%()\]\/\'\\\\|\[]#', "\x20", $str);

		// Delete all '?'
		$str = str_replace('?', '', $str);

		// Trim white spaces at beginning and end of alias and make lowercase
		$str = trim(String::strtolower($str));

		// Remove any duplicate whitespace and replace whitespaces by hyphens
		$str = preg_replace('#\x20+#', '-', $str);

		return $str;
	}
638897
public static function convertStringToPrefix($string) {
    $words = explode(' ', $string);
    $prefix = '';
    foreach ($words as $word) {
      $prefix .= substr($word, 0, 1);
    }
    return strtoupper($prefix);
  }
934148
private static function uncompressByteString($string)
    {
        $uncompressedString = '';
        $strLen = strlen($string);
        for ($i = 0; $i < $strLen; ++$i) {
            $uncompressedString .= $string[$i] . "\0";
        }

        return $uncompressedString;
    }
151788
public function escape_string($string)
    {
        if (!$this->connection) {
            return $string;
        }

        if ($string === null) {
            return $string;
        }
        return $this->connection->escape_string($string);
    }