Text.php
public static function crop($txt, int $maxChars = 20, string $etc = '...'): string
    {
        $txt = (string) $txt;
        if (mb_strlen($txt, self::ENCODING) > $maxChars) {
            return mb_substr($txt, 0, $maxChars - mb_strlen($etc, self::ENCODING), self::ENCODING) . $etc;
        }
        return $txt;
    }
public static function crop($txt, int $maxChars = 20, string $etc = '...'): string
    {
        $txt = (string) $txt;
        if (mb_strlen($txt, self::ENCODING) > $maxChars) {
            return mb_substr($txt, 0, $maxChars - mb_strlen($etc, self::ENCODING), self::ENCODING) . $etc;
        }
        return $txt;
    }
public static function crop ( $ txt , int $ maxChars = 20 , string $ etc = '...' ) : string { $ txt = ( string ) $ txt ; if ( mb_strlen ( $ txt , self :: ENCODING ) > $ maxChars ) { return mb_substr ( $ txt , 0 , $ maxChars - mb_strlen ( $ etc , self :: ENCODING ) , self :: ENCODING ) . $ etc ; } return $ txt ; }
Crop a string with a '...' if too long
@param type $txt
@param int $maxChars
@param string $etc
@return string
Crop a string with a ... if too long