ttl = $ttl; } public static function getSubscribedEvents(): array { return [ Events::JWT_CREATED => [ ['addClaims'], ], ]; } public function addClaims(JWTCreatedEvent $event): void { $claims = [ 'jti' => uniqid('', true), 'iat' => time(), 'nbf' => time(), ]; $data = $event->getData(); if (!array_key_exists('exp', $data) && $this->ttl > 0) { $claims['exp'] = time() + $this->ttl; } $event->setData(array_merge($claims, $data)); } }