<?php
namespace GemAcc;

final class ConfigValidator
{
    public static function validate(): array
    {
        $errors = [];
        $warnings = [];
        if (!defined('BOT_TOKEN') || trim((string)BOT_TOKEN) === '') $errors[] = 'BOT_TOKEN is empty';
        if (!defined('DB_HOST') || trim((string)DB_HOST) === '') $errors[] = 'DB_HOST is empty';
        if (!defined('DB_NAME') || trim((string)DB_NAME) === '') $errors[] = 'DB_NAME is empty';
        if (!defined('DB_USER') || trim((string)DB_USER) === '') $errors[] = 'DB_USER is empty';
        if (!defined('ADMIN_IDS') || trim((string)ADMIN_IDS) === '') $warnings[] = 'ADMIN_IDS is empty';
        if (defined('DB_PASS') && DB_PASS !== '' && preg_match('/^(password|changeme|123456)$/i', (string)DB_PASS)) $warnings[] = 'DB_PASS looks weak/default';
        if (!defined('TELEGRAM_SECRET_TOKEN') || trim((string)TELEGRAM_SECRET_TOKEN) === '') $warnings[] = 'WEBHOOK_SECRET/TELEGRAM_SECRET_TOKEN is empty; webhook origin is not protected';
        return ['ok'=>empty($errors), 'errors'=>$errors, 'warnings'=>$warnings];
    }
}
