Completed
Push — master ( 7a6b49...336156 )
by Camilo
02:22
created

DisconnectCleanup   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 26
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

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
    use ReadableContent;
13
14
    /**
15
     * @inheritdoc
16
     */
17 1
    public function performSpecialActions(ClientInterface $client, WritableContentInterface $originalRequest): bool
18
    {
19 1
        $successFullyClosed = $client->shutdownConnection();
20 1
        $this->logger->info('Sent shutdown signal to socket', ['successFullyClosed' => $successFullyClosed]);
21 1
        $client->setConnected(false);
22 1
        return true;
23
    }
24
25
    /**
26
     * @inheritdoc
27
     */
28 1
    public function getOriginControlPacket(): int
29
    {
30 1
        return 0;
31
    }
32
33 1
    public function fillObject(string $rawMQTTHeaders, ClientInterface $client): ReadableContentInterface
34
    {
35 1
        return $this;
36
    }
37
}
38