<?php

namespace goals\formats;

use goals\traits\goals_criteria_progress_alert_format_t;

class email_progress_alert_format implements \JsonSerializable
{
    use goals_criteria_progress_alert_format_t;

    private string $text;

    public const MAX_LEN = 1024;

    public function __construct(string $text)
    {
        $this->text = $text;
    }

    public function render(): string
    {
        $rendered = trim($this->text);
        if (mb_strlen($rendered) > self::MAX_LEN) {
            $rendered = mb_substr($rendered, 0, self::MAX_LEN);
        }
        return $rendered;
    }
}
