protected function prependChunkInformation($messageId, $data, $sequence, $sequenceSize)
{
if (!is_string($data) || $data === '') {
throw new InvalidArgumentException('Data must be a string and not be empty.');
}
if (!is_integer($sequence) || !is_integer($sequenceSize)) {
throw new InvalidArgumentException('Sequence number and size must be integer.');
}
if ($sequenceSize <= 0) {
throw new InvalidArgumentException('Sequence size must be greater than 0.');
}
if ($sequence > $sequenceSize) {
throw new InvalidArgumentException('Sequence size must be greater than sequence number.');
}
return pack('CC', 30, 15) . substr(md5($messageId, true), 0, 8) . pack('CC', $sequence, $sequenceSize) . $data;
}