Not sure about this - this is very much presentation related and not show-specific. Assuming this is called from a Twig template, there's a 'truncate' Twig filter which could be used or adapted.