| Conditions | 3 |
| Paths | 3 |
| Total Lines | 21 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 26 | 7 | public function normalize(JsonRpcResponse $response) |
|
| 27 | { |
||
| 28 | // Notifications must not have a response, even if they are on error |
||
| 29 | 7 | if ($response->isNotification()) { |
|
| 30 | 2 | return null; |
|
| 31 | } |
||
| 32 | |||
| 33 | $data = [ |
||
| 34 | 5 | self::KEY_JSON_RPC => $response->getJsonRpc(), |
|
| 35 | 5 | self::KEY_ID => $response->getId() |
|
| 36 | ]; |
||
| 37 | |||
| 38 | 5 | if ($response->getError()) { |
|
| 39 | 2 | $data[self::KEY_ERROR] = $this->normalizeError( |
|
| 40 | 2 | $response->getError() |
|
| 41 | ); |
||
| 42 | } else { |
||
| 43 | 3 | $data[self::KEY_RESULT] = $response->getResult(); |
|
| 44 | } |
||
| 45 | |||
| 46 | 5 | return $data; |
|
| 47 | } |
||
| 68 |