<?php

namespace App\Services\JWT;
use App\Services\JWTService;

class UsuarioLogado
{
    public static function getUsuarioId(): int
    {
        return JWTService::getTokenJWTPayload() ? JWTService::getTokenJWTPayload()->getUid() : 0;
    }

    public static function getProfileId(): int
    {
        return JWTService::getTokenJWTPayload() ? JWTService::getTokenJWTPayload()->getProfile() : 0;
    }

    public static function getPermissionsList(): array
    {
        return JWTService::getTokenJWTPayload() ? JWTService::getTokenJWTPayload()->getPermissions() : [];
    }

    public static function toArray(): array
    {
        return [
            'usuarioId' => self::getUsuarioId(),
            'permissions' => self::getPermissionsList(),
            'profileId' => self::getProfileId()
        ];
    }
}
