DisconnectCleanup::performSpecialActions()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 4
c 2
b 0
f 0
dl 0
loc 6
ccs 5
cts 5
cp 1
rs 10
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace unreal4u\MQTT\Internals;
6
7
/**
8
 * Performs some cleanup on the socket after disconnecting, this class is NOT a part of the MQTT protocol
9
 */
10
final class DisconnectCleanup extends ProtocolBase implements ReadableContentInterface
11
{
12 1
    use ReadableContent;
13
14
    private const CONTROL_PACKET_VALUE = 0;
15
16
    /**
17
     * @inheritdoc
18
     */
19 1
    public function performSpecialActions(ClientInterface $client, WritableContentInterface $originalRequest): bool
20
    {
21 1
        $successFullyClosed = $client->shutdownConnection();
22 1
        $this->logger->info('Sent shutdown signal to socket', ['successFullyClosed' => $successFullyClosed]);
23 1
        $client->setConnected(false);
24 1
        return true;
25
    }
26
27
    /**
28
     * @inheritdoc
29
     */
30 1
    public function getOriginControlPacket(): int
31
    {
32 1
        return 0;
33
    }
34
35 1
    public function fillObject(string $rawMQTTHeaders, ClientInterface $client): ReadableContentInterface
36
    {
37 1
        return $this;
38
    }
39
}
40