<?php

declare(strict_types=1);

namespace Install\Services;

final class InstallationEngine
{
    public function __construct(
        private readonly InstallationChecker $checker =
            new InstallationChecker(),
        private readonly InstallationReport $report =
            new InstallationReport()
    ) {
    }

    /**
     * @param array<string,mixed> $config
     * @param array<string,mixed> $database
     * @param array<string,mixed> $environment
     *
     * @return array<string,mixed>
     */
    public function prepare(
        array $config,
        array $database,
        array $environment
    ): array {
        $audit = $this->checker->audit(
            $config,
            $database,
            $environment
        );

        return $this->report->build($audit);
    }

    /**
     * @param array<string,mixed> $database
     */
    public function migrationRunner(
        array $database
    ): MigrationRunner {
        return new MigrationRunner($database);
    }
}
