<?php

declare(strict_types=1);

namespace Apexl\Tests\User\Helpers;

use DateTimeInterface;

trait ChecksDecodedJwtToken
{

    private function checkDecodedJwtToken(object $decoded, int $userId, string $sessionId, int $lifetime, DateTimeInterface $issuedAt, string $serverName): void
    {
        $this->assertSame($userId, $decoded->userId);
        $this->assertSame($sessionId, $decoded->sessionId);
        $this->assertSame($issuedAt->getTimestamp(), $decoded->iat);
        $this->assertSame($issuedAt->getTimestamp(), $decoded->nbf);
        $this->assertSame($issuedAt->modify(sprintf('+%s seconds', $lifetime))->getTimestamp(), $decoded->exp);
        $this->assertSame($serverName, $decoded->iss);
    }

    abstract public static function assertSame(mixed $expected, mixed $actual, string $message = ''): void;

}


