Verified Commit 3c8dd1cd authored by quietone's avatar quietone
Browse files

Issue #1965508 by jcorrao, smustgrave, ro-no-lo, isa.bel, xjm, nexusnovaz:...

Issue #1965508 by jcorrao, smustgrave, ro-no-lo, isa.bel, xjm, nexusnovaz: Improve doc block for Unicode::truncate()
parent 6937eea4
Loading
Loading
Loading
Loading
Loading
+19 −15
Original line number Diff line number Diff line
@@ -278,28 +278,32 @@ public static function ucwords($text) {
   *   An upper limit on the returned string length, including trailing ellipsis
   *   if $add_ellipsis is TRUE.
   * @param bool $wordsafe
   *   If TRUE, attempt to truncate on a word boundary. Word boundaries are
   *   spaces, punctuation, and Unicode characters used as word boundaries in
   *   non-Latin languages; see Unicode::PREG_CLASS_WORD_BOUNDARY for more
   *   information. If a word boundary cannot be found that would make the
   *   length of the returned string fall within length guidelines (see
   *   (optional) If TRUE, attempt to truncate on a word boundary. Word
   *   boundaries are spaces, punctuation, and Unicode characters used as word
   *   boundaries in non-Latin languages; see Unicode::PREG_CLASS_WORD_BOUNDARY
   *   for more information. If a word boundary cannot be found that would make
   *   the length of the returned string fall within length guidelines (see
   *   parameters $max_length and $min_wordsafe_length), word boundaries are
   *   ignored.
   *   ignored. Defaults to FALSE, which means the string will be truncated
   *   at the exact character position without considering word boundaries.
   * @param bool $add_ellipsis
   *   If TRUE, add '...' to the end of the truncated string (defaults to
   *   FALSE). The string length will still fall within $max_length.
   *   (optional) If TRUE, add '...' to the end of the truncated string. The
   *   string length will still fall within $max_length. Defaults to FALSE,
   *   which means no ellipsis will be added to the truncated string.
   * @param int $min_wordsafe_length
   *   If $wordsafe is TRUE, the minimum acceptable length for truncation
   *   (before adding an ellipsis, if $add_ellipsis is TRUE). Has no effect if
   *   $wordsafe is FALSE. This can be used to prevent having a very short
   *   resulting string that will not be understandable. For instance, if you
   *   are truncating the string "See MyVeryLongURLExample.com for more
   *   (optional) If $wordsafe is TRUE, the minimum acceptable length for
   *   truncation (before adding an ellipsis, if $add_ellipsis is TRUE). Has no
   *   effect if $wordsafe is FALSE. This can be used to prevent having a very
   *   short resulting string that will not be understandable. For instance, if
   *   you are truncating the string "See MyVeryLongURLExample.com for more
   *   information" to a word-safe return length of 20, the only available word
   *   boundary within 20 characters is after the word "See", which wouldn't
   *   leave a very informative string. If you had set $min_wordsafe_length to
   *   10, though, the function would realize that "See" alone is too short, and
   *   would then just truncate ignoring word boundaries, giving you "See
   *   MyVeryLongURL..." (assuming you had set $add_ellipsis to TRUE).
   *   would then just truncate ignoring word boundaries, giving you
   *   "See MyVeryLongURL..." (assuming you had set $add_ellipsis to TRUE).
   *   Defaults to 1, which means any word-safe truncation result of at least
   *   1 character will be acceptable.
   *
   * @return string
   *   The truncated string.