<?php

namespace App\Support;

class LogContext
{
    public static function excerpt(string $text, int $limit = 160): string
    {
        $text = trim(preg_replace('/\s+/', ' ', $text) ?? '');

        if (mb_strlen($text) <= $limit) {
            return $text;
        }

        return mb_substr($text, 0, $limit) . '…';
    }

    public static function sha1(string $text): string
    {
        return sha1($text);
    }
}

