LogContext.php 430 B

1234567891011121314151617181920212223
  1. <?php
  2. namespace App\Support;
  3. class LogContext
  4. {
  5. public static function excerpt(string $text, int $limit = 160): string
  6. {
  7. $text = trim(preg_replace('/\s+/', ' ', $text) ?? '');
  8. if (mb_strlen($text) <= $limit) {
  9. return $text;
  10. }
  11. return mb_substr($text, 0, $limit) . '…';
  12. }
  13. public static function sha1(string $text): string
  14. {
  15. return sha1($text);
  16. }
  17. }