public function cropMiddle($text, $maxLength, $delimiter = '...')
{
// return text if it doesn't need to be cropped
if (!$text || strlen($text) <= $maxLength || !substr($text, 0)) {
return $text;
}
$substrLength = floor(($maxLength - strlen($delimiter)) / 2);
return substr($text, 0, $substrLength) . $delimiter . substr($text, -$substrLength);
}