<?php

declare(strict_types=1);

namespace BotGuard\Services\License;

/**
 * Immutable result of a license activation / verification attempt.
 *
 * `mode` is one of:
 *   - "licensed" — activated against the license server
 *   - "offline"  — no server configured or unreachable, running in offline/trial
 *   - "invalid"  — the server rejected the key/domain
 */
final class LicenseStatus
{
    public function __construct(
        public readonly bool $valid,
        public readonly string $mode,
        public readonly string $message,
        public readonly ?string $token = null,
        public readonly ?string $expiresAt = null,
    ) {
    }

    public static function licensed(string $token, ?string $expiresAt, string $message = 'License activated.'): self
    {
        return new self(true, 'licensed', $message, $token, $expiresAt);
    }

    public static function offline(string $message = 'Running in offline/trial mode.'): self
    {
        return new self(true, 'offline', $message);
    }

    public static function invalid(string $message): self
    {
        return new self(false, 'invalid', $message);
    }
}
