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