private function truncate($text, $length, $suffix = '...')
    {
        $computedLength = $length - strlen($suffix);

        return strlen($text) > $computedLength ? substr($text, 0, $computedLength) . $suffix : $text;
    }
private function truncate($text, $length, $suffix = '...')
    {
        $computedLength = $length - strlen($suffix);

        return strlen($text) > $computedLength ? substr($text, 0, $computedLength) . $suffix : $text;
    }
private function truncate ( $ text , $ length , $ suffix = '...' ) { $ computedLength = $ length - strlen ( $ suffix ) ; return strlen ( $ text ) > $ computedLength ? substr ( $ text , 0 , $ computedLength ) . $ suffix : $ text ; }
Truncate the given string.

See: https://github.com/symfony/symfony/issues/11977

@param string $text Text to truncate
@param int $length Length
@param string $suffix Suffix to append

@return string
Truncate the given string .