<?php

declare(strict_types=1);

namespace App\Services\Install;

/**
 * Web 安装向导执行阶段（用于日志与失败归类，避免迁移后误报「库不可安装」）。
 */
enum WebInstallPhase: string
{
    case CheckingDatabase = 'checking_database';
    case WritingEnv = 'writing_env';
    case Migrating = 'migrating';
    case Seeding = 'seeding';
    case CreatingAdmin = 'creating_admin';
    case UpdatingSystemProfile = 'updating_system_profile';
    case WritingInstallMarkers = 'writing_install_markers';
    case RunningOptionalFinalizers = 'running_optional_finalizers';
    case Completed = 'completed';

    /**
     * @return list<self>
     */
    public static function ordered(): array
    {
        return [
            self::CheckingDatabase,
            self::WritingEnv,
            self::Migrating,
            self::Seeding,
            self::CreatingAdmin,
            self::UpdatingSystemProfile,
            self::WritingInstallMarkers,
            self::RunningOptionalFinalizers,
            self::Completed,
        ];
    }

    public function labelZh(): string
    {
        return match ($this) {
            self::CheckingDatabase => '检查数据库与部署路径',
            self::WritingEnv => '写入环境配置',
            self::Migrating => '执行数据库迁移',
            self::Seeding => '写入安装种子数据',
            self::CreatingAdmin => '创建超级管理员',
            self::UpdatingSystemProfile => '更新系统档案',
            self::WritingInstallMarkers => '写入已安装标记',
            self::RunningOptionalFinalizers => '可选收尾（存储链接与缓存）',
            self::Completed => '安装完成',
        };
    }
}
