<?php

declare(strict_types=1);

namespace App\Services\Install;

/**
 * Web 安装对外入口；具体步骤由 {@see DBErpWebInstallCoordinator} 编排。
 */
final class DBErpInstallService
{
    public function __construct(
        private readonly DBErpWebInstallCoordinator $webInstallCoordinator,
    ) {}

    /**
     * @param  array{
     *     system_url: string,
     *     timezone: string,
     *     admin_name: string,
     *     login_account: string,
     *     admin_email?: string|null,
     *     password: string,
     *     reinstall_reset?: bool,
     * }  $payload
     */
    public function run(array $payload): void
    {
        $this->webInstallCoordinator->execute($payload);
    }

    /**
     * @param  array{
     *     system_url: string,
     *     timezone: string,
     *     admin_name: string,
     *     login_account: string,
     *     admin_email?: string|null,
     *     password: string,
     *     reinstall_reset?: bool,
     * }  $payload
     * @return list<string>
     */
    public function runWithFinalizationWarnings(array $payload): array
    {
        return $this->webInstallCoordinator->executeWithWarnings($payload);
    }
}
