String to upper and trim

@param $string
@return string

@SuppressWarnings(PHPMD.ShortMethodName)
8269
public static function up($string): string
    {
        $cleaned = Str::up($string);
        $cleaned = Str::trim($cleaned);

        return $cleaned;
    }
393411
private function convertToUrlFriendlyString($string)
    {
        foreach (static::charsArray() as $key => $val) {
            $string = str_replace($val, mb_substr($key, 0, 1), $string);
        }

        return preg_replace('/[^\x20-\x7E]/u', '', $string);
    }
25103
public static function clearData( $string ) {
		$trim = trim( $string );
		$out  = htmlspecialchars( $trim, ENT_QUOTES );

		return $out;
	}
171033
public static function low($string): string
    {
        $cleaned = Str::low($string);
        $cleaned = Str::trim($cleaned);

        return $cleaned;
    }
1212732
public static function slugify($string)
    {
        // Replace non-alpha-numerics with dashes
        $string = strtolower(preg_replace(array('/[^a-zA-Z0-9 -]/','/[ -]+/','/^-|-$/'), array('','-',''), $string));

        // Trim dashes from the left side of the string
        $string = ltrim($string, "-");

        // Trim dashes from the right side of the string
        $string = rtrim($string, '-');

        return $string;
    }
335810
public function nlToPbr($string)
	{
		$string = trim($string);
		$string = Modifiers::linebreaks($string);
		$string = str_replace("\n", '<br />', $string);
		$string = str_replace('<br /><br />', "</p>\n<p>", $string);
		$string = str_replace('<p></p>', '', $string);
		return '<p>' . $string . '</p>' . PHP_EOL;
	}
589175
public function convertNewlines($string) {
        $string = str_replace("\r\n", "\n", $string);
        $string = str_replace("\r", "\n", $string);

        return $this->cleanNewlines($string);
    }
299783
public static function toSingleWhitespace($string, $trim = true)
    {
        $string = preg_replace("/\r|\n|\t/", " ", $string);
        $string = preg_replace("/ {2,}/", " ", $string);

        if ($trim) {
            $string = self::trim($string);
        }

        return $string;
    }
466092
public static function underscore($string) {
        return static::cache(array(__METHOD__, $string), function() use ($string) {
            return trim(mb_strtolower(str_replace('__', '_', preg_replace('/([A-Z]{1})/', '_$1', preg_replace('/[^_a-z0-9]+/i', '', preg_replace('/[\s]+/', '_', $string))))), '_');
        });
    }
719838
final public static function handlifyString($string)
    {
        $string = preg_replace('/\W+/', '_', $string);
        $string = preg_replace('/([A-Z])/', '_$1', $string);
        $string = strtolower($string);
        $string = preg_replace('/_+/', '_', trim($string, '_'));

        return $string;
    }
293302
public function sanitizeString($string)
    {
        $string = str_replace('_', '-', GeneralUtility::camelCaseToLowerCaseUnderscored($string));

        while (strpos($string, '--')) {
            $string = str_replace('--', '-', $string);
        }

        return $string;
    }
1223662
public static function upperCase(?string $string = null): ?string
    {
        if ($string === null) {
            return null;
        }

        return mb_strtoupper($string, 'UTF-8');
    }
57164
public function normalize($string) {
		$string = $this->_normalize($string, ['clean' => true, 'case' => true]);
		return implode('-', str_split($string, $this->_partLength));
	}
252230
static
	public String trim(String string){
		int length = string.length();

		int trimmedLength = length;

		while(trimmedLength > 0){
			char c = string.charAt(trimmedLength - 1);

			if(!Character.isWhitespace(c)){
				break;
			}

			trimmedLength--;
		}

		if(trimmedLength < length){
			string = string.substring(0, trimmedLength);
		}

		return string;
	}
875256
public function truncate($string, $endlength="30", $end="...")
        {
            $strlen = strlen($string);

            if ($strlen > $endlength) {
                $trim = $endlength - $strlen;
                $string = substr($string, 0, $trim);
                $string .= $end;
            }

            return $string;
        }
415874
protected function convertToStringOrBoolean($string)
    {
        $result = (string) $string;
        $lowerString = strtolower($result);

        if('true' === $lowerString)
        {
            $result = true;
        }
        elseif('false' === $lowerString)
        {
            $result = false;
        }

        return $result;
    }
812177
private function underscore($string)
    {
        $string = preg_replace('/(?<=[a-z])([A-Z])/', '_$1', $string);

        if ($this->case === CASE_UPPER) {
            return strtoupper($string);
        }

        return strtolower($string);
    }