src/Str.php
public static function truncate(string $string, int $maxLength, string $indicator = '...'): string
    {
        if (mb_strlen($string) > $maxLength) {
            $string = mb_substr($string, 0, $maxLength - mb_strlen($indicator)) . $indicator;
        }

        return $string;
    }
public static function truncate(string $string, int $maxLength, string $indicator = '...'): string
    {
        if (mb_strlen($string) > $maxLength) {
            $string = mb_substr($string, 0, $maxLength - mb_strlen($indicator)) . $indicator;
        }

        return $string;
    }
public static function truncate ( string $ string , int $ maxLength , string $ indicator = '...' ) : string { if ( mb_strlen ( $ string ) > $ maxLength ) { $ string = mb_substr ( $ string , 0 , $ maxLength - mb_strlen ( $ indicator ) ) . $ indicator ; } return $ string ; }
Get shortened string.

@param string $string
@param int    $maxLength
@param string $indicator
@return string
Get shortened string .