<?php
declare(strict_types=1);

function platform_enabled(PDO $pdo, int $userId, string $platform): bool
{
    $stmt = $pdo->prepare("
        SELECT enabled
        FROM user_platform_access
        WHERE user_id = ?
          AND platform = ?
        LIMIT 1
    ");
    $stmt->execute([$userId, $platform]);

    $enabled = $stmt->fetchColumn();

    // No row = enabled by default
    if ($enabled === false) {
        return true;
    }

    return (int)$enabled === 1;
}
