original_string: public static function shorten($string, $limit = 25, $glue = ' &hellip; ') {
          if (mb_strlen($string) > $limit) {
              $width = round($limit / 2);
  
              // prefix
              $pre = mb_substr($string, 0, $width);
  
              if (mb_substr($pre, -1) !== ' ' && ($i = static::lastIndexOf($pre, ' '))) {
                  $pre = mb_substr($pre, 0, $i);
              }
  
              // suffix
              $suf = mb_substr($string, -$width);
  
              if (mb_substr($suf, 0, 1) !== ' ' && ($i = static::indexOf($suf, ' '))) {
                  $suf = mb_substr($suf, $i);
              }
  
              return trim($pre) . $glue . trim($suf);
          }
  
          return $string;
      }
code: public static function shorten($string, $limit = 25, $glue = ' &hellip; ') {
          if (mb_strlen($string) > $limit) {
              $width = round($limit / 2);
  
              // prefix
              $pre = mb_substr($string, 0, $width);
  
              if (mb_substr($pre, -1) !== ' ' && ($i = static::lastIndexOf($pre, ' '))) {
                  $pre = mb_substr($pre, 0, $i);
              }
  
              // suffix
              $suf = mb_substr($string, -$width);
  
              if (mb_substr($suf, 0, 1) !== ' ' && ($i = static::indexOf($suf, ' '))) {
                  $suf = mb_substr($suf, $i);
              }
  
              return trim($pre) . $glue . trim($suf);
          }
  
          return $string;
      }
code_tokens: public static function shorten ( $ string , $ limit = 25 , $ glue = ' &hellip; ' ) { if ( mb_strlen ( $ string ) > $ limit ) { $ width = round ( $ limit / 2 ) ; // prefix $ pre = mb_substr ( $ string , 0 , $ width ) ; if ( mb_substr ( $ pre , - 1 ) !== ' ' && ( $ i = static :: lastIndexOf ( $ pre , ' ' ) ) ) { $ pre = mb_substr ( $ pre , 0 , $ i ) ; } // suffix $ suf = mb_substr ( $ string , - $ width ) ; if ( mb_substr ( $ suf , 0 , 1 ) !== ' ' && ( $ i = static :: indexOf ( $ suf , ' ' ) ) ) { $ suf = mb_substr ( $ suf , $ i ) ; } return trim ( $ pre ) . $ glue . trim ( $ suf ) ; } return $ string ; }
docstring: If a string is too long, shorten it in the middle while also respecting whitespace and preserving words.
  
  @param string $string
  @param int $limit
  @param string $glue
  @return string
docstring_tokens: If a string is too long shorten it in the middle while also respecting whitespace and preserving words .