<?php

declare(strict_types=1);

namespace PpPhp\Core\Diagnostics\Engine;

use PpPhp\Core\Diagnostics\Context\DiagnosticContext;
use PpPhp\Core\Diagnostics\Registry\DiagnosticProviderRegistry;
use PpPhp\Core\Diagnostics\Results\DiagnosticReport;

final class DiagnosticsEngine
{
    public function __construct(
        private readonly DiagnosticProviderRegistry $providers = new DiagnosticProviderRegistry()
    ) {
    }

    public function providers(): DiagnosticProviderRegistry
    {
        return $this->providers;
    }

    public function run(DiagnosticContext $context): DiagnosticReport
    {
        $report = new DiagnosticReport();

        foreach ($this->providers->all() as $provider) {
            $report->add($provider->diagnose($context));
        }

        return $report;
    }
}
