src/Protocol/JoinGroup.php
public function encode(array $payloads = []): string
    {
        if (! isset($payloads['group_id'])) {
            throw new ProtocolException('given join group data invalid. `group_id` is undefined.');
        }

        if (! isset($payloads['session_timeout'])) {
            throw new ProtocolException('given join group data invalid. `session_timeout` is undefined.');
        }

        if (! isset($payloads['member_id'])) {
            throw new ProtocolException('given join group data invalid. `member_id` is undefined.');
        }

        if (! isset($payloads['data'])) {
            throw new ProtocolException('given join group data invalid. `data` is undefined.');
        }

        if (! isset($payloads['protocol_type'])) {
            $payloads['protocol_type'] = 'consumer';
        }

        if (! isset($payloads['rebalance_timeout'])) {
            $payloads['rebalance_timeout'] = $payloads['session_timeout'];
        }

        $header = $this->requestHeader('kafka-php', self::JOIN_GROUP_REQUEST, self::JOIN_GROUP_REQUEST);
        $data   = self::encodeString($payloads['group_id'], self::PACK_INT16);
        $data  .= self::pack(self::BIT_B32, (string) $payloads['session_timeout']);

        if ($this->getApiVersion(self::JOIN_GROUP_REQUEST) === self::API_VERSION1) {
            $data .= self::pack(self::BIT_B32, (string) $payloads['rebalance_timeout']);
        }

        $data .= self::encodeString($payloads['member_id'], self::PACK_INT16);
        $data .= self::encodeString($payloads['protocol_type'], self::PACK_INT16);
        $data .= self::encodeArray($payloads['data'], [$this, 'encodeGroupProtocol']);
        $data  = self::encodeString($header . $data, self::PACK_INT32);

        return $data;
    }
public function encode(array $payloads = []): string
    {
        if (! isset($payloads['group_id'])) {
            throw new ProtocolException('given join group data invalid. `group_id` is undefined.');
        }

        if (! isset($payloads['session_timeout'])) {
            throw new ProtocolException('given join group data invalid. `session_timeout` is undefined.');
        }

        if (! isset($payloads['member_id'])) {
            throw new ProtocolException('given join group data invalid. `member_id` is undefined.');
        }

        if (! isset($payloads['data'])) {
            throw new ProtocolException('given join group data invalid. `data` is undefined.');
        }

        if (! isset($payloads['protocol_type'])) {
            $payloads['protocol_type'] = 'consumer';
        }

        if (! isset($payloads['rebalance_timeout'])) {
            $payloads['rebalance_timeout'] = $payloads['session_timeout'];
        }

        $header = $this->requestHeader('kafka-php', self::JOIN_GROUP_REQUEST, self::JOIN_GROUP_REQUEST);
        $data   = self::encodeString($payloads['group_id'], self::PACK_INT16);
        $data  .= self::pack(self::BIT_B32, (string) $payloads['session_timeout']);

        if ($this->getApiVersion(self::JOIN_GROUP_REQUEST) === self::API_VERSION1) {
            $data .= self::pack(self::BIT_B32, (string) $payloads['rebalance_timeout']);
        }

        $data .= self::encodeString($payloads['member_id'], self::PACK_INT16);
        $data .= self::encodeString($payloads['protocol_type'], self::PACK_INT16);
        $data .= self::encodeArray($payloads['data'], [$this, 'encodeGroupProtocol']);
        $data  = self::encodeString($header . $data, self::PACK_INT32);

        return $data;
    }
@param mixed[] $payloads

@throws NotSupported
@throws ProtocolException