Total Complexity | 8 |
Total Lines | 47 |
Duplicated Lines | 0 % |
Coverage | 63.16% |
Changes | 0 |
1 | <?php |
||
16 | final class Response |
||
17 | { |
||
18 | public const TYPE_ERROR = 0x8000; |
||
19 | |||
20 | private $header; |
||
21 | private $body; |
||
22 | |||
23 | 182 | public function __construct(array $header, array $body) |
|
24 | { |
||
25 | 182 | $this->header = $header; |
|
26 | 182 | $this->body = $body; |
|
27 | 182 | } |
|
28 | |||
29 | 180 | public function isError() : bool |
|
34 | } |
||
35 | |||
36 | 26 | public function getCode() : int |
|
37 | { |
||
38 | 26 | return $this->header[IProto::CODE]; |
|
39 | } |
||
40 | |||
41 | public function getSync() : int |
||
42 | { |
||
43 | return $this->header[IProto::SYNC]; |
||
44 | } |
||
45 | |||
46 | public function getSchemaId() : int |
||
47 | { |
||
48 | return $this->header[IProto::SCHEMA_ID]; |
||
49 | } |
||
50 | |||
51 | 176 | public function getBodyField(int $code) |
|
52 | { |
||
53 | 176 | if (!isset($this->body[$code])) { |
|
54 | throw new \OutOfBoundsException(\sprintf('Invalid body code 0x%x.', $code)); |
||
55 | } |
||
56 | |||
57 | 176 | return $this->body[$code]; |
|
58 | } |
||
59 | |||
60 | public function tryGetBodyField(int $code, $default = null) |
||
63 | } |
||
64 | } |
||
65 |