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

EmptyWritableResponse   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

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 WritableContent;
20
21
    const CONTROL_PACKET_VALUE = 0;
22
23
    /**
24
     * Creates the variable header that each method has
25
     * @return string
26
     */
27 1
    public function createVariableHeader(): string
28
    {
29 1
        return '';
30
    }
31
32
    /**
33
     * Creates the actual payload to be sent
34
     * @return string
35
     */
36 1
    public function createPayload(): string
37
    {
38 1
        return '';
39
    }
40
41
    /**
42
     * Some responses won't expect an answer back, others do in some situations
43
     * @return bool
44
     */
45 1
    public function shouldExpectAnswer(): bool
46
    {
47 1
        return false;
48
    }
49
}
50