| Total Complexity | 8 |
| Total Lines | 93 |
| 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 | /** |
||
| 28 | * @param int $queryType |
||
| 29 | * @param array $query |
||
| 30 | * @param OptionsInterface $options |
||
| 31 | */ |
||
| 32 | 22 | public function __construct(int $queryType = null, array $query = null, OptionsInterface $options = null) |
|
| 33 | { |
||
| 34 | 22 | $this->queryType = $queryType ?? QueryType::START; |
|
| 35 | 22 | $this->query = $query ?? []; |
|
| 36 | 22 | $this->options = $options ?? new Options(); |
|
| 37 | 22 | } |
|
| 38 | |||
| 39 | /** |
||
| 40 | * @inheritdoc |
||
| 41 | */ |
||
| 42 | 1 | public function getQueryType(): int |
|
| 43 | { |
||
| 44 | 1 | return $this->queryType; |
|
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * @inheritdoc |
||
| 49 | */ |
||
| 50 | 1 | public function setCommand(int $queryType): MessageInterface |
|
| 51 | { |
||
| 52 | 1 | $this->queryType = $queryType; |
|
| 53 | |||
| 54 | 1 | return $this; |
|
| 55 | } |
||
| 56 | |||
| 57 | /** |
||
| 58 | * @inheritdoc |
||
| 59 | */ |
||
| 60 | 17 | public function setQuery($query): MessageInterface |
|
| 61 | { |
||
| 62 | 17 | $this->query = (array) $query; |
|
| 63 | |||
| 64 | 17 | return $this; |
|
| 65 | } |
||
| 66 | |||
| 67 | /** |
||
| 68 | * @inheritdoc |
||
| 69 | */ |
||
| 70 | 18 | public function getOptions(): OptionsInterface |
|
| 71 | { |
||
| 72 | 18 | return $this->options; |
|
| 73 | } |
||
| 74 | |||
| 75 | /** |
||
| 76 | * @inheritdoc |
||
| 77 | */ |
||
| 78 | 20 | public function setOptions(OptionsInterface $options): MessageInterface |
|
| 79 | { |
||
| 80 | 20 | $this->options = $options; |
|
| 81 | |||
| 82 | 20 | return $this; |
|
| 83 | } |
||
| 84 | |||
| 85 | /** |
||
| 86 | * @inheritdoc |
||
| 87 | */ |
||
| 88 | 18 | public function toArray(): array |
|
| 89 | { |
||
| 90 | return [ |
||
| 91 | 18 | $this->queryType, |
|
| 92 | 18 | $this->query, |
|
| 93 | 18 | (object) $this->getOptions() |
|
| 94 | ]; |
||
| 95 | } |
||
| 96 | |||
| 97 | /** |
||
| 98 | * @return array |
||
| 99 | */ |
||
| 100 | 16 | public function jsonSerialize(): array |
|
| 103 | } |
||
| 104 | } |
||
| 105 |