Completed
Push — master ( d94a2b...d27c94 )
by Camilo
02:20
created

PubComp   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 6
dl 0
loc 57
ccs 0
cts 11
cp 0
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A fillObject() 0 4 1
A expectAnswer() 0 3 1
A createPayload() 0 4 1
A originPacketIdentifier() 0 3 1
A shouldExpectAnswer() 0 3 1
A createVariableHeader() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace unreal4u\MQTT\Protocol;
6
7
use unreal4u\MQTT\Application\EmptyReadableResponse;
8
use unreal4u\MQTT\Internals\ClientInterface;
9
use unreal4u\MQTT\Internals\ProtocolBase;
10
use unreal4u\MQTT\Internals\ReadableContent;
11
use unreal4u\MQTT\Internals\ReadableContentInterface;
12
use unreal4u\MQTT\Internals\WritableContent;
13
use unreal4u\MQTT\Internals\WritableContentInterface;
14
15
/**
16
 * The PUBCOMP Packet is the response to a PUBREL Packet.
17
 *
18
 * It is the fourth and final packet of the QoS 2 protocol exchange.
19
 */
20
final class PubComp extends ProtocolBase implements ReadableContentInterface, WritableContentInterface
21
{
22
    use ReadableContent, WritableContent;
23
24
    public $packetIdentifier = 0;
25
26
    const CONTROL_PACKET_VALUE = 7;
27
28
    public function fillObject(string $rawMQTTHeaders, ClientInterface $client): ReadableContentInterface
29
    {
30
        $this->packetIdentifier = $this->extractPacketIdentifier($rawMQTTHeaders);
31
        return $this;
32
    }
33
34
    /**
35
     * Creates the variable header that each method has
36
     * @return string
37
     */
38
    public function createVariableHeader(): string
39
    {
40
        // TODO: Implement createVariableHeader() method.
41
        return '';
42
    }
43
44
    /**
45
     * Creates the actual payload to be sent
46
     * @return string
47
     */
48
    public function createPayload(): string
49
    {
50
        // TODO: Implement createPayload() method.
51
        return '';
52
    }
53
54
    /**
55
     * @inheritdoc
56
     */
57
    public function expectAnswer(string $data, ClientInterface $client): ReadableContentInterface
58
    {
59
        return new EmptyReadableResponse($this->logger);
60
    }
61
62
    /**
63
     * Some responses won't expect an answer back, others do in some situations
64
     * @return bool
65
     */
66
    public function shouldExpectAnswer(): bool
67
    {
68
        return false;
69
    }
70
71
    /**
72
     * @inheritdoc
73
     */
74
    public function originPacketIdentifier(): int
75
    {
76
        return PubRel::getControlPacketValue();
77
    }
78
}
79