<?php

declare(strict_types=1);

namespace PpPhp\Core\Maintenance\Results;

final class MaintenanceIssue
{
    public const INFO = 'info';
    public const WARNING = 'warning';
    public const ERROR = 'error';

    public function __construct(
        public readonly string $severity,
        public readonly string $message,
        public readonly string $source = '',
        public readonly string $suggestion = '',
        public readonly array $metadata = []
    ) {
    }

    public function isError(): bool
    {
        return $this->severity === self::ERROR;
    }

    public function isWarning(): bool
    {
        return $this->severity === self::WARNING;
    }

    public function toArray(): array
    {
        return [
            'severity' => $this->severity,
            'message' => $this->message,
            'source' => $this->source,
            'suggestion' => $this->suggestion,
            'metadata' => $this->metadata,
        ];
    }
}
