Disconnect   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 8
c 1
b 0
f 0
dl 0
loc 29
ccs 9
cts 9
cp 1
rs 10

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 /** @noinspection TraitsPropertiesConflictsInspection */
22 1
        WritableContent;
23
24
    private const CONTROL_PACKET_VALUE = 14;
25
26 1
    public function createVariableHeader(): string
27
    {
28 1
        return '';
29
    }
30
31 1
    public function createPayload(): string
32
    {
33 1
        return '';
34
    }
35
36 1
    public function expectAnswer(string $brokerBitStream, ClientInterface $client): ReadableContentInterface
37
    {
38 1
        return new DisconnectCleanup($this->logger);
39
    }
40
41
    /**
42
     * A disconnect should never expect an answer back
43
     * @return bool
44
     */
45 1
    public function shouldExpectAnswer(): bool
46
    {
47 1
        return false;
48
    }
49
}
50