Total Complexity | 10 |
Total Lines | 60 |
Duplicated Lines | 0 % |
Coverage | 95% |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
16 | final class Response |
||
17 | { |
||
18 | public const TYPE_ERROR = 0x8000; |
||
19 | |||
20 | private $header; |
||
21 | private $body; |
||
22 | |||
23 | 480 | public function __construct(array $header, array $body) |
|
24 | { |
||
25 | 480 | $this->header = $header; |
|
26 | 480 | $this->body = $body; |
|
27 | } |
||
28 | |||
29 | 390 | public function isError() : bool |
|
34 | } |
||
35 | |||
36 | 81 | public function getCode() : int |
|
39 | } |
||
40 | |||
41 | 411 | public function getSync() : int |
|
44 | } |
||
45 | |||
46 | 3 | public function getSchemaId() : int |
|
49 | } |
||
50 | |||
51 | /** |
||
52 | * @return mixed |
||
53 | */ |
||
54 | 395 | public function getBodyField(int $key) |
|
55 | { |
||
56 | 395 | if (\array_key_exists($key, $this->body)) { |
|
57 | 395 | return $this->body[$key]; |
|
58 | } |
||
59 | |||
60 | throw new \OutOfRangeException(\sprintf('The body key 0x%x does not exist', $key)); |
||
61 | } |
||
62 | |||
63 | /** |
||
64 | * @param mixed $default |
||
65 | * |
||
66 | * @return mixed |
||
67 | */ |
||
68 | 96 | public function tryGetBodyField(int $key, $default = null) |
|
69 | { |
||
70 | 96 | return \array_key_exists($key, $this->body) ? $this->body[$key] : $default; |
|
71 | } |
||
72 | |||
73 | 6 | public function hasBodyField(int $key) : bool |
|
76 | } |
||
77 | } |
||
78 |