<?php

class UserService
{
    public static function getById($userId)
    {
        $stmt = db()->prepare("SELECT id, name, email, telegram_chat_id FROM users WHERE id = ?");
        $stmt->execute([$userId]);
        return $stmt->fetch(PDO::FETCH_ASSOC);
    }

    public static function updateProfile($userId, $name, $email, $telegramChatId)
    {
        $stmt = db()->prepare("
            UPDATE users
            SET name = ?, email = ?, telegram_chat_id = ?
            WHERE id = ?
        ");

        return $stmt->execute([
            $name,
            $email,
            $telegramChatId,
            $userId
        ]);
    }
}