| Conditions | 3 |
| Paths | 3 |
| Total Lines | 22 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 36 | function psr7_response_decode(array $json): ResponseInterface |
||
| 37 | { |
||
| 38 | $properties = [ |
||
| 39 | 2 | 'protocol_version', |
|
| 40 | 'status_code', |
||
| 41 | 'reason_phrase', |
||
| 42 | 'headers', |
||
| 43 | 'body', |
||
| 44 | ]; |
||
| 45 | |||
| 46 | 2 | foreach ($properties as $property) { |
|
| 47 | 2 | if (!isset($json[$property])) { |
|
| 48 | 2 | throw new NotAnEncodedResponseException($json); |
|
| 49 | } |
||
| 50 | } |
||
| 51 | |||
| 52 | 2 | return new Response( |
|
| 53 | 2 | $json['status_code'], |
|
| 54 | 2 | $json['headers'], |
|
| 55 | 2 | $json['body'], |
|
| 56 | 2 | $json['protocol_version'], |
|
| 57 | 2 | $json['reason_phrase'] |
|
| 58 | ); |
||
| 60 |