| Conditions | 4 |
| Paths | 3 |
| Total Lines | 14 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 20 |
| Changes | 0 | ||
| 1 | <?php |
||
| 23 | public function createFor(\Exception $exception) : JsonRpcExceptionInterface |
||
| 24 | { |
||
| 25 | $errorCode = (int) $exception->getCode(); |
||
| 26 | if ($errorCode < self::MIN_VALID_ERROR_CODE || $errorCode > self::MAX_VALID_ERROR_CODE) { |
||
| 27 | return new JsonRpcInternalErrorException($exception); |
||
| 28 | } |
||
| 29 | |||
| 30 | $data = []; |
||
| 31 | |||
| 32 | if ($exception->getPrevious()) { |
||
| 33 | $data[self::ERROR_DATA_PREVIOUS_KEY] = $exception->getPrevious(); |
||
| 34 | } |
||
| 35 | |||
| 36 | return new JsonRpcException($errorCode, $exception->getMessage(), $data); |
||
| 37 | } |
||
| 39 |