public static function encodeString($string, $bytes, $compression = self::COMPRESSION_NONE)
{
$packLen = $bytes == self::PACK_INT32 ? self::BIT_B32 : self::BIT_B16;
switch ($compression) {
case self::COMPRESSION_NONE:
break;
case self::COMPRESSION_GZIP:
$string = \gzencode($string);
break;
case self::COMPRESSION_SNAPPY:
throw new \Kafka\Exception\NotSupported('SNAPPY compression not yet implemented');
default:
throw new \Kafka\Exception\NotSupported('Unknown compression flag: ' . $compression);
}
return self::pack($packLen, strlen($string)) . $string;
}