for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace unreal4u\MQTT\Protocol;
use unreal4u\MQTT\Exceptions\UnmatchingPacketIdentifiers;
use unreal4u\MQTT\Internals\ClientInterface;
use unreal4u\MQTT\Internals\ProtocolBase;
use unreal4u\MQTT\Internals\ReadableContent;
use unreal4u\MQTT\Internals\ReadableContentInterface;
use unreal4u\MQTT\Internals\WritableContentInterface;
/**
* The UNSUBACK Packet is sent by the Server to the Client to confirm receipt of an UNSUBSCRIBE Packet.
*/
final class UnsubAck extends ProtocolBase implements ReadableContentInterface
{
use ReadableContent;
const CONTROL_PACKET_VALUE = 11;
* @var int
private $packetIdentifier = 0;
public function fillObject(string $rawMQTTHeaders, ClientInterface $client): ReadableContentInterface
// Read the rest of the request out should only 1 byte have come in
if (\strlen($rawMQTTHeaders) === 1) {
$rawMQTTHeaders .= $client->readBrokerData(3);
}
$this->packetIdentifier = $this->extractPacketIdentifier($rawMQTTHeaders);
return $this;
* @inheritdoc
* @throws \LogicException
public function performSpecialActions(ClientInterface $client, WritableContentInterface $originalRequest): bool
/** @var Unsubscribe $originalRequest */
if ($this->packetIdentifier !== $originalRequest->getPacketIdentifier()) {
throw new UnmatchingPacketIdentifiers('Packet identifiers do not match!');
$client->updateLastCommunication();
return true;
public function getOriginControlPacket(): int
return Unsubscribe::getControlPacketValue();