Disconnect::createPayload()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 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