<?php

namespace Kylin\Licensing\Exceptions;

use Kylin\Licensing\Enums\LicensingErrorCode;

/**
 * 许可证过期异常
 */
class LicenseExpiredException extends \RuntimeException
{
    private bool $inGracePeriod = false;

    public function __construct(
        public readonly LicensingErrorCode $errorCode,
        ?string $message = null,
    ) {
        parent::__construct($message ?? $errorCode->message());
    }

    public function isInGracePeriod(): bool
    {
        return $this->inGracePeriod;
    }

    public function setInGracePeriod(bool $inGracePeriod): self
    {
        $this->inGracePeriod = $inGracePeriod;
        return $this;
    }
}
