public function truncate($message, $length, $suffix = '...')
    {
        $computedLength = $length - $this->strlen($suffix);

        if ($computedLength > $this->strlen($message)) {
            return $message;
        }

        if (false === $encoding = mb_detect_encoding($message, null, true)) {
            return substr($message, 0, $length).$suffix;
        }

        return mb_substr($message, 0, $length, $encoding).$suffix;
    }
public function truncate($message, $length, $suffix = '...')
    {
        $computedLength = $length - $this->strlen($suffix);

        if ($computedLength > $this->strlen($message)) {
            return $message;
        }

        if (false === $encoding = mb_detect_encoding($message, null, true)) {
            return substr($message, 0, $length).$suffix;
        }

        return mb_substr($message, 0, $length, $encoding).$suffix;
    }
public function truncate ( $ message , $ length , $ suffix = '...' ) { $ computedLength = $ length - $ this -> strlen ( $ suffix ) ; if ( $ computedLength > $ this -> strlen ( $ message ) ) { return $ message ; } if ( false === $ encoding = mb_detect_encoding ( $ message , null , true ) ) { return substr ( $ message , 0 , $ length ) . $ suffix ; } return mb_substr ( $ message , 0 , $ length , $ encoding ) . $ suffix ; }
Truncates a message to the given length.

@param string $message
@param int    $length
@param string $suffix

@return string
Truncates a message to the given length .