<?php

declare(strict_types=1);

namespace App\Framework\Database\Monitoring\Health;

/**
 * Represents the status of a health check
 */
final readonly class HealthCheckStatus
{
    /**
     * Status constants
     */
    public const OK = 'ok';
    public const WARNING = 'warning';
    public const ERROR = 'error';

    private function __construct(
        public string $status,
        public string $message
    ) {
    }

    /**
     * Create an OK status
     */
    public static function ok(string $message): self
    {
        return new self(self::OK, $message);
    }

    /**
     * Create a warning status
     */
    public static function warning(string $message): self
    {
        return new self(self::WARNING, $message);
    }

    /**
     * Create an error status
     */
    public static function error(string $message): self
    {
        return new self(self::ERROR, $message);
    }

    /**
     * Check if the status is OK
     */
    public function isOk(): bool
    {
        return $this->status === self::OK;
    }

    /**
     * Check if the status is a warning
     */
    public function isWarning(): bool
    {
        return $this->status === self::WARNING;
    }

    /**
     * Check if the status is an error
     */
    public function isError(): bool
    {
        return $this->status === self::ERROR;
    }

    /**
     * Get the status as an array
     * @return array<string, string>
     */
    public function toArray(): array
    {
        return [
            'status' => $this->status,
            'message' => $this->message,
        ];
    }
}
