DisconnectCleanup   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getOriginControlPacket() 0 3 1
A fillObject() 0 3 1
A performSpecialActions() 0 6 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