Skip to content

Commit

Permalink
fix truncate filter
Browse files Browse the repository at this point in the history
  • Loading branch information
matronator committed May 12, 2023
1 parent 540624b commit 8b3d226
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Parsem/Filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ public static function random(array|string $array): mixed

public static function truncate(string $string, int $length, string $ending = '...'): string
{
if (mb_strlen($string, static::ENCODING) <= $length) {
return $string;
}

return mb_substr($string, 0, $length, static::ENCODING) . $ending;
}
}

0 comments on commit 8b3d226

Please sign in to comment.