Passed
Push — main ( 31df87...01449a )
by Evgenii
02:07
created

MindBoxRequest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Test Coverage

Coverage 66.67%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 11
c 1
b 0
f 0
dl 0
loc 57
ccs 8
cts 12
cp 0.6667
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getOperationName() 0 3 1
A getBodyAsJson() 0 3 1
A isAsync() 0 3 1
A getDeviceUUID() 0 3 1
A getBody() 0 3 1
A getMode() 0 3 1
1
<?php
2
3
4
namespace floor12\MindBox\Requests;
5
6
7
use floor12\MindBox\MindBoxClient;
8
9
abstract class MindBoxRequest
10
{
11
    /** @var string */
12
    protected $operationName;
13
    /** @var array */
14
    protected $body = [];
15
    /** @var string|null */
16
    protected $deviceUUID;
17
    /** @var int */
18
    protected $mode = MindBoxClient::MODE_SYNCHRONOUS;
19
20
    /**
21
     * @return string
22
     */
23 1
    public function getOperationName()
24
    {
25 1
        return $this->operationName;
26
    }
27
28
    /**
29
     * @return string|null
30
     */
31 1
    public function getDeviceUUID(): ?string
32
    {
33 1
        return $this->deviceUUID;
34
    }
35
36
    /**
37
     * @return array
38
     */
39
    public function getBody(): array
40
    {
41
        return $this->body;
42
    }
43
44
    /**
45
     * @return string
46
     */
47 1
    public function getBodyAsJson(): string
48
    {
49 1
        return json_encode($this->body);
50
    }
51
52
    /**
53
     * @return int
54
     */
55
    public function getMode(): int
56
    {
57
        return $this->mode;
58
    }
59
60
    /**
61
     * @return bool
62
     */
63 1
    public function isAsync(): bool
64
    {
65 1
        return $this->mode === MindBoxClient::MODE_ASYNCHRONOUS;
66
    }
67
}
68