public static function fromJson(
        string $name,
        bool $endsWithSession,
        DateTimeImmutable $issuedAt,
        string $json
    ) : self {
        $cookie = new self($name, $endsWithSession, $issuedAt);
        $cookie->data = json_decode($json, true);

        if (! is_array($cookie->data)) {
            throw JsonException::fromJsonDecodeError(json_last_error_msg());
        }

        return $cookie;
    }