Upgrade to 4.1.1

This commit is contained in:
Bastian Allgeier
2024-02-26 11:15:36 +01:00
parent 9345fc1a0b
commit 2e8aa1ed80
20 changed files with 123 additions and 171 deletions

View File

@@ -488,7 +488,16 @@ class Str
return $string;
}
return static::substr($string, 0, mb_strrpos(static::substr($string, 0, $chars), ' ')) . $rep;
// shorten the string to the specified number of characters,
// but make sure to not cut off in the middle of a word
$excerpt = static::substr($string, 0, $chars);
$cutoff = mb_strrpos($excerpt, ' ');
if ($cutoff !== false) {
$excerpt = static::substr($string, 0, $cutoff);
}
return $excerpt . $rep;
}
/**