Passed
Push — master ( c1f248...257530 )
by Camilo
01:51
created

DisconnectCleanup::fillObject()   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
use unreal4u\MQTT\Client;
8
9
/**
10
 * Performs some cleanup on the socket after disconnecting, this class is NOT a part of the MQTT protocol
11
 */
12
final class DisconnectCleanup extends ProtocolBase implements ReadableContentInterface
13
{
14
    use ReadableContent;
15
16
    /**
17
     * @inheritdoc
18
     */
19
    public function performSpecialActions(Client $client, WritableContentInterface $originalRequest): bool
20
    {
21
        $successFullyClosed = stream_socket_shutdown($client->socket, STREAM_SHUT_RDWR);
22
        $information['successfullyClosed'] = $successFullyClosed;
0 ignored issues
show
Comprehensibility Best Practice introduced by
$information was never initialized. Although not strictly required by PHP, it is generally a good practice to add $information = array(); before regardless.
Loading history...
23
        $this->logger->info('Sent shutdown signal to socket', $information);
24
        $client->setConnected(false);
25
        return true;
26
    }
27
}
28