diff --git a/CHANGELOG.md b/CHANGELOG.md index c33248e..0568207 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - New #156: Add `NumericHelper::trimDecimalZeros()` (@samdark, @vjik) - Enh #163: Explicitly import classes, functions, and constants in "use" sections (@vjik) +- Enh #167: Remove dead code in `StringHelper::truncateWordsByLength()` (@vjik) ## 2.7.0 November 23, 2025 diff --git a/src/StringHelper.php b/src/StringHelper.php index 03bb8f3..a1a8fb7 100644 --- a/src/StringHelper.php +++ b/src/StringHelper.php @@ -382,10 +382,8 @@ public static function truncateWordsByLength( // Prefer not to break words if there's a space within the snippet. $lastSpace = mb_strrpos($truncated, ' ', 0, $encoding); if ($lastSpace !== false) { - $cut = rtrim(mb_substr($truncated, 0, $lastSpace, $encoding)); - return $cut === '' - ? mb_substr($trimMarker, 0, $length, $encoding) - : $cut . $trimMarker; + return rtrim(mb_substr($truncated, 0, $lastSpace, $encoding)) + . $trimMarker; } return $truncated . $trimMarker;