<?php

namespace App\Utils;

use Firebase\JWT\JWT as FirebaseJWT;
use Firebase\JWT\Key;

class JWT
{
    public static function encode($payload)
    {
        $key = getenv('JWT_SECRET') ?: 'default_secret';
        return FirebaseJWT::encode($payload, $key, 'HS256');
    }

    public static function decode($token)
    {
        $key = getenv('JWT_SECRET') ?: 'default_secret';
        return FirebaseJWT::decode($token, new Key($key, 'HS256'));
    }
}
