<?php
declare(strict_types=1);

function notify_user(
    PDO $pdo,
    int $userId,
    string $type,
    string $title,
    string $message,
    ?string $entityType = null,
    ?int $entityId = null
): void {

    $stmt = $pdo->prepare("
        INSERT INTO notifications (
            user_id,
            type,
            title,
            message,
            entity_type,
            entity_id
        ) VALUES (
            :user,
            :type,
            :title,
            :message,
            :entity_type,
            :entity_id
        )
    ");

    $stmt->execute([
        'user' => $userId,
        'type' => $type,
        'title' => $title,
        'message' => $message,
        'entity_type' => $entityType,
        'entity_id' => $entityId
    ]);
}
