<?php

declare(strict_types=1);

namespace BotGuard\Models;

use BotGuard\Core\Model;

/**
 * Detection module registry rows (enabled flag + weight + settings).
 */
final class ModuleConfig extends Model
{
    protected string $table = 'module_configs';

    /**
     * @return array<int, array<string, mixed>>
     */
    public function ordered(): array
    {
        return $this->all('`sort_order` ASC');
    }

    public function setEnabledAndWeight(string $moduleKey, bool $enabled, float $weight): int
    {
        return $this->db->update(
            $this->table,
            ['enabled' => $enabled ? 1 : 0, 'weight' => $weight],
            ['module_key' => $moduleKey]
        );
    }
}
