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

MindBoxRequest   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 8
eloc 13
c 1
b 0
f 0
dl 0
loc 73
rs 10
ccs 17
cts 17
cp 1

8 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 setMode() 0 3 1
A setDeviceUUID() 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 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