src/Protocol/Fetch.php
protected function fetchPartition(string $data): array
    {
        $offset              = 0;
        $partitionId         = self::unpack(self::BIT_B32, substr($data, $offset, 4));
        $offset             += 4;
        $errorCode           = self::unpack(self::BIT_B16_SIGNED, substr($data, $offset, 2));
        $offset             += 2;
        $highwaterMarkOffset = self::unpack(self::BIT_B64, substr($data, $offset, 8));
        $offset             += 8;

        $messageSetSize = self::unpack(self::BIT_B32, substr($data, $offset, 4));
        $offset        += 4;

        $messages = [];

        if ($messageSetSize > 0 && $offset < strlen($data)) {
            $messages = $this->decodeMessageSetArray(substr($data, $offset, $messageSetSize), $messageSetSize);

            $offset += $messages['length'];
        }

        return [
            'length' => $offset,
            'data'   => [
                'partition'           => $partitionId,
                'errorCode'           => $errorCode,
                'highwaterMarkOffset' => $highwaterMarkOffset,
                'messageSetSize'      => $messageSetSize,
                'messages'            => $messages['data'] ?? [],
            ],
        ];
    }
protected function fetchPartition(string $data): array
    {
        $offset              = 0;
        $partitionId         = self::unpack(self::BIT_B32, substr($data, $offset, 4));
        $offset             += 4;
        $errorCode           = self::unpack(self::BIT_B16_SIGNED, substr($data, $offset, 2));
        $offset             += 2;
        $highwaterMarkOffset = self::unpack(self::BIT_B64, substr($data, $offset, 8));
        $offset             += 8;

        $messageSetSize = self::unpack(self::BIT_B32, substr($data, $offset, 4));
        $offset        += 4;

        $messages = [];

        if ($messageSetSize > 0 && $offset < strlen($data)) {
            $messages = $this->decodeMessageSetArray(substr($data, $offset, $messageSetSize), $messageSetSize);

            $offset += $messages['length'];
        }

        return [
            'length' => $offset,
            'data'   => [
                'partition'           => $partitionId,
                'errorCode'           => $errorCode,
                'highwaterMarkOffset' => $highwaterMarkOffset,
                'messageSetSize'      => $messageSetSize,
                'messages'            => $messages['data'] ?? [],
            ],
        ];
    }
@return mixed[]

@throws ProtocolException