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

Disconnect::expectAnswer()   A

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