original_string: public static function truncate($string, $limit = 150, $up_to_break = false, $break = ' ', $pad = '&hellip;')
      {
          // return with no change if string is shorter than $limit
          if (mb_strlen($string) <= $limit) {
              return $string;
          }
  
          // is $break present between $limit and the end of the string?
          if ($up_to_break && false !== ($breakpoint = mb_strpos($string, $break, $limit))) {
              if ($breakpoint < mb_strlen($string) - 1) {
                  $string = mb_substr($string, 0, $breakpoint) . $pad;
              }
          } else {
              $string = mb_substr($string, 0, $limit) . $pad;
          }
  
          return $string;
      }
code: public static function truncate($string, $limit = 150, $up_to_break = false, $break = ' ', $pad = '&hellip;')
      {
          // return with no change if string is shorter than $limit
          if (mb_strlen($string) <= $limit) {
              return $string;
          }
  
          // is $break present between $limit and the end of the string?
          if ($up_to_break && false !== ($breakpoint = mb_strpos($string, $break, $limit))) {
              if ($breakpoint < mb_strlen($string) - 1) {
                  $string = mb_substr($string, 0, $breakpoint) . $pad;
              }
          } else {
              $string = mb_substr($string, 0, $limit) . $pad;
          }
  
          return $string;
      }
code_tokens: public static function truncate ( $ string , $ limit = 150 , $ up_to_break = false , $ break = ' ' , $ pad = '&hellip;' ) { // return with no change if string is shorter than $limit if ( mb_strlen ( $ string ) <= $ limit ) { return $ string ; } // is $break present between $limit and the end of the string? if ( $ up_to_break && false !== ( $ breakpoint = mb_strpos ( $ string , $ break , $ limit ) ) ) { if ( $ breakpoint < mb_strlen ( $ string ) - 1 ) { $ string = mb_substr ( $ string , 0 , $ breakpoint ) . $ pad ; } } else { $ string = mb_substr ( $ string , 0 , $ limit ) . $ pad ; } return $ string ; }
docstring: Truncate text by number of characters but can cut off words.
  
  @param  string $string
  @param  int    $limit       Max number of characters.
  @param  bool   $up_to_break truncate up to breakpoint after char count
  @param  string $break       Break point.
  @param  string $pad         Appended padding to the end of the string.
  
  @return string
docstring_tokens: Truncate text by number of characters but can cut off words .