<?php

declare(strict_types=1);

namespace App\Domain\Domain\Enums;

/**
 * Domain provisioning durumu.
 *
 * Geçişler:
 *   pending → provisioning → active   (mutlu yol)
 *   pending → error                    (preflight başarısız)
 *   provisioning → error               (Apache config geçmedi)
 *   error → provisioning               (retry)
 *   active → provisioning              (config update)
 */
enum DomainStatus: string
{
    case Pending = 'pending';
    case Provisioning = 'provisioning';
    case Active = 'active';
    case Error = 'error';

    public function label(): string
    {
        return match ($this) {
            self::Pending => 'Bekliyor',
            self::Provisioning => 'Kuruluyor',
            self::Active => 'Aktif',
            self::Error => 'Hata',
        };
    }

    public function isHealthy(): bool
    {
        return $this === self::Active;
    }

    public function canRetry(): bool
    {
        return $this === self::Error;
    }
}
