EmptyWritableResponse   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A createPayload() 0 3 1
A createVariableHeader() 0 3 1
A shouldExpectAnswer() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace unreal4u\MQTT\Application;
6
7
use unreal4u\MQTT\Internals\ProtocolBase;
8
use unreal4u\MQTT\Internals\WritableContent;
9
use unreal4u\MQTT\Internals\WritableContentInterface;
10
11
/**
12
 * This is an example of a payload class that performs some processing on the data
13
 *
14
 * This particular case will prepend a datetime to the message itself. It will json_encode() it into the payload and
15
 * when retrieving it will set the public property $originalPublishDateTime.
16
 */
17
final class EmptyWritableResponse extends ProtocolBase implements WritableContentInterface
18
{
19
    use /** @noinspection TraitsPropertiesConflictsInspection */
20 1
        WritableContent;
21
22
    private const CONTROL_PACKET_VALUE = 0;
23
24
    /**
25
     * Creates the variable header that each method has
26
     * @return string
27
     */
28 1
    public function createVariableHeader(): string
29
    {
30 1
        return '';
31
    }
32
33
    /**
34
     * Creates the actual payload to be sent
35
     * @return string
36
     */
37 1
    public function createPayload(): string
38
    {
39 1
        return '';
40
    }
41
42
    /**
43
     * Some responses won't expect an answer back, others do in some situations
44
     * @return bool
45
     */
46 1
    public function shouldExpectAnswer(): bool
47
    {
48 1
        return false;
49
    }
50
}
51