Total Complexity | 8 |
Total Lines | 67 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
10 | class Message implements MessageInterface |
||
11 | { |
||
12 | /** |
||
13 | * @var int |
||
14 | */ |
||
15 | private $queryType; |
||
16 | |||
17 | /** |
||
18 | * @var array |
||
19 | */ |
||
20 | private $query; |
||
21 | |||
22 | /** |
||
23 | * @var OptionsInterface |
||
24 | */ |
||
25 | private $options; |
||
26 | |||
27 | public function __construct(int $queryType = null, array $query = null, OptionsInterface $options = null) |
||
28 | { |
||
29 | $this->queryType = $queryType ?? QueryType::START; |
||
30 | $this->query = $query ?? []; |
||
31 | $this->options = $options ?? new Options(); |
||
32 | 22 | } |
|
33 | |||
34 | 22 | public function getQueryType(): int |
|
35 | 22 | { |
|
36 | 22 | return $this->queryType; |
|
37 | 22 | } |
|
38 | |||
39 | public function setCommand(int $queryType): MessageInterface |
||
40 | { |
||
41 | $this->queryType = $queryType; |
||
42 | 1 | ||
43 | return $this; |
||
44 | 1 | } |
|
45 | |||
46 | public function setQuery($query): MessageInterface |
||
47 | { |
||
48 | $this->query = (array) $query; |
||
49 | |||
50 | 1 | return $this; |
|
51 | } |
||
52 | 1 | ||
53 | public function getOptions(): OptionsInterface |
||
54 | 1 | { |
|
55 | return $this->options; |
||
56 | } |
||
57 | |||
58 | public function setOptions(OptionsInterface $options): MessageInterface |
||
59 | { |
||
60 | 17 | $this->options = $options; |
|
61 | |||
62 | 17 | return $this; |
|
63 | } |
||
64 | 17 | ||
65 | public function toArray(): array |
||
66 | { |
||
67 | return [ |
||
68 | $this->queryType, |
||
69 | $this->query, |
||
70 | 18 | (object) $this->getOptions() |
|
71 | ]; |
||
72 | 18 | } |
|
73 | |||
74 | public function jsonSerialize(): array |
||
77 | } |
||
78 | } |
||
79 |