Completed
Push — master ( f445a9...55498a )
by Camilo
02:27
created

Disconnect   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
dl 0
loc 28
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A shouldExpectAnswer() 0 3 1
A expectAnswer() 0 3 1
A createPayload() 0 3 1
A createVariableHeader() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace unreal4u\MQTT\Protocol;
6
7
use unreal4u\MQTT\Internals\ClientInterface;
8
use unreal4u\MQTT\Internals\ProtocolBase;
9
use unreal4u\MQTT\Internals\DisconnectCleanup;
10
use unreal4u\MQTT\Internals\ReadableContentInterface;
11
use unreal4u\MQTT\Internals\WritableContent;
12
use unreal4u\MQTT\Internals\WritableContentInterface;
13
14
/**
15
 * The DISCONNECT Packet is the final Control Packet sent from the Client to the Server.
16
 *
17
 * It indicates that the Client is disconnecting cleanly.
18
 */
19
final class Disconnect extends ProtocolBase implements WritableContentInterface
20
{
21
    use WritableContent;
22
23
    const CONTROL_PACKET_VALUE = 14;
24
25 1
    public function createVariableHeader(): string
26
    {
27 1
        return '';
28
    }
29
30 1
    public function createPayload(): string
31
    {
32 1
        return '';
33
    }
34
35 1
    public function expectAnswer(string $data, ClientInterface $client): ReadableContentInterface
36
    {
37 1
        return new DisconnectCleanup($this->logger);
38
    }
39
40
    /**
41
     * A disconnect should never expect an answer back
42
     * @return bool
43
     */
44 1
    public function shouldExpectAnswer(): bool
45
    {
46 1
        return false;
47
    }
48
}
49