original_string: public static function shorten($text, $maxlength = 140, $end = '[...]') {
          $maxlength++;
          if (mb_strlen($text) > $maxlength) {
              $subex = mb_substr($text, 0, $maxlength - 5);
              $exwords = explode(' ', $subex);
              $excut = - (mb_strlen($exwords[count($exwords)-1]));
              if ($excut < 0) {
                  $text = mb_substr($subex, 0, $excut);
              } else {
                  $text = $subex;
              }
              $text .= $end;
          }
          return $text;
      }
code: public static function shorten($text, $maxlength = 140, $end = '[...]') {
          $maxlength++;
          if (mb_strlen($text) > $maxlength) {
              $subex = mb_substr($text, 0, $maxlength - 5);
              $exwords = explode(' ', $subex);
              $excut = - (mb_strlen($exwords[count($exwords)-1]));
              if ($excut < 0) {
                  $text = mb_substr($subex, 0, $excut);
              } else {
                  $text = $subex;
              }
              $text .= $end;
          }
          return $text;
      }
code_tokens: public static function shorten ( $ text , $ maxlength = 140 , $ end = '[...]' ) { $ maxlength ++ ; if ( mb_strlen ( $ text ) > $ maxlength ) { $ subex = mb_substr ( $ text , 0 , $ maxlength - 5 ) ; $ exwords = explode ( ' ' , $ subex ) ; $ excut = - ( mb_strlen ( $ exwords [ count ( $ exwords ) - 1 ] ) ) ; if ( $ excut < 0 ) { $ text = mb_substr ( $ subex , 0 , $ excut ) ; } else { $ text = $ subex ; } $ text .= $ end ; } return $ text ; }
docstring: Builds an excerpt from a longer text.
  
  @param string  $text      the input text
  @param integer $maxlength maximal length of the text
  @param string  $end       a string that will be attached to the short version of $text
  
  @return string
docstring_tokens: Builds an excerpt from a longer text .