<?php

declare(strict_types=1);

namespace External\HannahBundle\Util\User;

use KupShop\KupShopBundle\Util\Database\QueryHint;

class UserUtil
{
    public function getUserCard(int $userId): ?string
    {
        $cards = QueryHint::withRouteToMaster(function () use ($userId) {
            $user = \User::createFromId($userId);

            return $user->getCustomData(true)['sap']['cards'] ?? [];
        });

        if ($card = reset($cards)) {
            return (string) $card;
        }

        return null;
    }
}
