protected function encodeMessageSet(array $messages, int $compression = self::COMPRESSION_NONE): string
    {
        $data = '';
        $next = 0;

        foreach ($messages as $message) {
            $encodedMessage = $this->encodeMessage($message);

            $data .= self::pack(self::BIT_B64, (string) $next)
                   . self::encodeString($encodedMessage, self::PACK_INT32);

            ++$next;
        }

        if ($compression === self::COMPRESSION_NONE) {
            return $data;
        }

        return self::pack(self::BIT_B64, '0')
             . self::encodeString($this->encodeMessage($data, $compression), self::PACK_INT32);
    }
protected function encodeMessageSet(array $messages, int $compression = self::COMPRESSION_NONE): string
    {
        $data = '';
        $next = 0;

        foreach ($messages as $message) {
            $encodedMessage = $this->encodeMessage($message);

            $data .= self::pack(self::BIT_B64, (string) $next)
                   . self::encodeString($encodedMessage, self::PACK_INT32);

            ++$next;
        }

        if ($compression === self::COMPRESSION_NONE) {
            return $data;
        }

        return self::pack(self::BIT_B64, '0')
             . self::encodeString($this->encodeMessage($data, $compression), self::PACK_INT32);
    }
protected function encodeMessageSet ( array $ messages , int $ compression = self :: COMPRESSION_NONE ) : string { $ data = '' ; $ next = 0 ; foreach ( $ messages as $ message ) { $ encodedMessage = $ this -> encodeMessage ( $ message ) ; $ data .= self :: pack ( self :: BIT_B64 , ( string ) $ next ) . self :: encodeString ( $ encodedMessage , self :: PACK_INT32 ) ; ++ $ next ; } if ( $ compression === self :: COMPRESSION_NONE ) { return $ data ; } return self :: pack ( self :: BIT_B64 , '0' ) . self :: encodeString ( $ this -> encodeMessage ( $ data , $ compression ) , self :: PACK_INT32 ) ; }
encode message set
N.B., MessageSets are not preceded by an int32 like other array elements
in the protocol.

@param string[]|string[][] $messages

@throws NotSupported
encode message set N . B . MessageSets are not preceded by an int32 like other array elements in the protocol .