protected function calculateExpiryTime(int $lifetime = null): \DateTime
    {
        if ($lifetime === self::UNLIMITED_LIFETIME || ($lifetime === null && $this->defaultLifetime === self::UNLIMITED_LIFETIME)) {
            return new \DateTime(self::DATETIME_EXPIRYTIME_UNLIMITED, new \DateTimeZone('UTC'));
        }

        if ($lifetime === null) {
            $lifetime = $this->defaultLifetime;
        }
        return new \DateTime('now +' . $lifetime . ' seconds', new \DateTimeZone('UTC'));
    }