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