@param string $str

@return string
556696
public static function java_truncate(string $str): string
    {
        if (strlen($str) > 955) {
            return substr($str, 0, 475).'[...]'.substr($str, -475);
        }

        return $str;
    }
1110372
public static function toAscii(string $str) : string
    {
        $clean = preg_replace('/[^a-zA-Z0-9\.\/_|+ -]/', '', $str);
        $clean = strtolower(trim($clean, '-'));
        $clean = preg_replace('/[\/_|+ -]+/', '-', $clean);

        return $clean;
    }
1095932
protected function _a($str) {
		$self=$this;
		return preg_replace_callback(
			'/(?<!\\\\)\[(.+?)(?!\\\\)\]\h*\(<?(.*?)>?(?:\h*"(.*?)"\h*)?\)/',
			function($expr) use($self) {
				return '<a href="'.$self->esc($expr[2]).'"'.
					(empty($expr[3])?
						'':
						(' title="'.$self->esc($expr[3]).'"')).
					'>'.$self->scan($expr[1]).'</a>';
			},
			$str
		);
	}
1180679
public static function humanize(string $str): string
    {
        $result = preg_replace(
            [
                '/([A-Z])/',
                '/[-\s]+/',
                '/[_\s]+/',
            ],
            [
                '_$1',
                ' ',
                ' ',
            ],
            static::removeMultipleSpaces($str)
        );

        return mb_ucfirst(mb_strtolower($result));
    }
1320007
public function str2bin(string $str):string {
		$chrs = unpack('C*', $str);

		return vsprintf(str_repeat('%08b', count($chrs)), $chrs);
	}
400582
public static function realEscape($str)
    {
        $str = trim($str, "\"'");

        $return = "CONCAT(";
        $len = \strlen($str);

        for ($i = 0; $i < $len; ++$i) {
            $return .= "CHAR(".ord($str[$i])."),";
        }

        if ($i > 0) {
            $return = substr($return, 0, -1);
        } else {
            $return = "\"\"";
        }
        $return .= ")";

        return $return;
    }
1182403
public static function strrev($str)
    {
        $result = '';
        $strLen = static::length($str);

        if (!$strLen) {
            return $result;
        }

        for ($i = $strLen - 1; $i >= 0; $i--) {
            $result .= static::substr($str, $i, 1);
        }

        return $result;
    }
462876
protected function _a($str) {
		return preg_replace_callback(
			'/(?<!\\\\)\[(.+?)(?!\\\\)\]\h*\(<?(.*?)>?(?:\h*"(.*?)"\h*)?\)/',
			function($expr) {
				return '<a href="'.$this->esc($expr[2]).'"'.
					(empty($expr[3])?
						'':
						(' title="'.$this->esc($expr[3]).'"')).
					'>'.$this->scan($expr[1]).'</a>';
			},
			$str
		);
	}
1168183
public static function toSMS($str) {
        $str = str_replace(array(' ', 'é', 'è', 'ó', 'à', 'â', ',', '?', "'"), array('+', '%E9', '%E8', 'o', '%E0', '%E2', '%82', '%3F', "%27"), $str);

        return $str;
    }
285666
private function toCamelCase($str)
    {
        // Split string in words.
        $words = preg_split('/[-_]/', strtolower($str)); //explode('_', strtolower($str));

        $return = '';
        foreach ($words as $word) {
            $return .= ucfirst(trim($word));
        }

        return $return;
    }
652919
public static function rot47($str)
    {
        $result = '';
        foreach (str_split($str) as $char) {
            $ord = ord($char);
            $result .= (namespace\Utils::numberBetween($ord, 33, 126))
                ? chr(namespace\Utils::numberWrap($ord + 47, 33, 126))
                : $char;
        }
        return $result;
    }
762411
public static function slug($str)
    {
        $str = strtolower($str);
        $str = preg_replace('/[^a-z0-9]/i', '-', $str);
        $str = preg_replace('/-+/', '-', $str);
        $str = preg_replace('/-$|^-/', '', $str);

        return $str;
    }
568000
public static function cleanForOrder(string $str): string
  {
    $str = self::removeAccents($str);
    $str = preg_replace("/^[^a-z0-9 ]/i", "", $str);
    $str = trim($str);
    return $str;
  }
72984
public static function toString($str){
		$str = strtoupper($str);

		// csSave actually has to be able to consider extra characters
		if(self::$charset === Base32Characters::CROCKFORD){
			$str = str_replace('O', '0', $str);
			$str = str_replace(['I', 'L'], '1', $str);
		}

		return self::bin2str(self::toBin($str));
	}
1138689
private function filterQueryOrFragment(string $str): string
    {
        return \preg_replace_callback(
            '/(?:[^' . self::CHAR_UNRESERVED . self::CHAR_SUB_DELIMS . '%:@\/\?]++|%(?![A-Fa-f0-9]{2}))/',
            [$this, 'urlEncodeChar'],
            $str
        );
    }
885138
public static function nailDecode(String $str) : String
    {
        $str = str_replace(array_values(self::$nailChars), array_keys(self::$nailChars), $str);

        return $str;
    }
584390
public static function before($str)
    {
        $str = str_replace('\\', '/', $str);
        $i = strrpos($str, '/');
        if ($i === false) {
            return $str;
        }

        return substr($str, 0, $i);
    }