<?php

declare(strict_types=1);

namespace PpPhp\Core\Maintenance\Engine;

use PpPhp\Core\Maintenance\Registry\MaintenanceProviderRegistry;
use PpPhp\Core\Maintenance\Results\MaintenanceReport;

final class MaintenanceEngine
{
    public function __construct(
        private readonly MaintenanceProviderRegistry $providers = new MaintenanceProviderRegistry()
    ) {
    }

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

    public function run(string $basePath): MaintenanceReport
    {
        $report = new MaintenanceReport();

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

        return $report;
    }
}
