src/Protocol/SaslHandShake.php
public function encode(array $payloads = []): string
    {
        $mechanism = array_shift($payloads);

        if (! is_string($mechanism)) {
            throw new ProtocolException('Invalid request SASL hand shake mechanism given. ');
        }

        if (! in_array($mechanism, self::ALLOW_SASL_MECHANISMS, true)) {
            throw new ProtocolException(
                'Invalid request SASL hand shake mechanism given, it must be one of: ' . implode('|', self::ALLOW_SASL_MECHANISMS)
            );
        }

        $header = $this->requestHeader('kafka-php', self::SASL_HAND_SHAKE_REQUEST, self::SASL_HAND_SHAKE_REQUEST);
        $data   = self::encodeString($mechanism, self::PACK_INT16);
        $data   = self::encodeString($header . $data, self::PACK_INT32);

        return $data;
    }
public function encode(array $payloads = []): string
    {
        $mechanism = array_shift($payloads);

        if (! is_string($mechanism)) {
            throw new ProtocolException('Invalid request SASL hand shake mechanism given. ');
        }

        if (! in_array($mechanism, self::ALLOW_SASL_MECHANISMS, true)) {
            throw new ProtocolException(
                'Invalid request SASL hand shake mechanism given, it must be one of: ' . implode('|', self::ALLOW_SASL_MECHANISMS)
            );
        }

        $header = $this->requestHeader('kafka-php', self::SASL_HAND_SHAKE_REQUEST, self::SASL_HAND_SHAKE_REQUEST);
        $data   = self::encodeString($mechanism, self::PACK_INT16);
        $data   = self::encodeString($header . $data, self::PACK_INT32);

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

@throws NotSupported
@throws ProtocolException