Completed
Push — master ( accf18...c40548 )
by Camilo
02:13
created

DisconnectCleanup::getOriginControlPacket()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
crap 2
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
    public function performSpecialActions(ClientInterface $client, WritableContentInterface $originalRequest): bool
18
    {
19
        $successFullyClosed = $client->shutdownConnection();
20
        $this->logger->info('Sent shutdown signal to socket', ['successFullyClosed' => $successFullyClosed]);
21
        $client->setConnected(false);
22
        return true;
23
    }
24
25
    /**
26
     * @inheritdoc
27
     */
28
    public function getOriginControlPacket(): int
29
    {
30
        return 0;
31
    }
32
}
33