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