Passed
Push — main ( 01449a...f97206 )
by Evgenii
02:10
created

MindBoxRequest::setMode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
ccs 2
cts 2
cp 1
cc 1
nc 1
nop 1
crap 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 2
    public function getDeviceUUID(): ?string
32
    {
33 2
        return $this->deviceUUID;
34
    }
35
36
    /**
37
     * @return array
38
     */
39 1
    public function getBody(): array
40
    {
41 1
        return $this->body;
42
    }
43
44
    /**
45
     * @return string
46
     */
47 2
    public function getBodyAsJson(): string
48
    {
49 2
        return json_encode($this->body);
50
    }
51
52
    /**
53
     * @return int
54
     */
55 1
    public function getMode(): int
56
    {
57 1
        return $this->mode;
58
    }
59
60
    /**
61
     * @return bool
62
     */
63 2
    public function isAsync(): bool
64
    {
65 2
        return $this->mode === MindBoxClient::MODE_ASYNCHRONOUS;
66
    }
67
68
    /**
69
     * @param string|null $deviceUUID
70
     */
71 1
    public function setDeviceUUID(?string $deviceUUID): void
72
    {
73 1
        $this->deviceUUID = $deviceUUID;
74 1
    }
75
76
    /**
77
     * @param int $mode
78
     */
79 3
    public function setMode(int $mode): void
80
    {
81 3
        $this->mode = $mode;
82 3
    }
83
}
84