Conditions | 4 |
Paths | 3 |
Total Lines | 20 |
Code Lines | 14 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 4.0072 |
Changes | 0 |
1 | <?php |
||
15 | function throwable_encode($throwable) |
||
16 | { |
||
17 | 2 | if (!($throwable instanceof Exception) || !($throwable instanceof Throwable)) { |
|
|
|||
18 | throw new NotAThrowableException($throwable); |
||
19 | } |
||
20 | |||
21 | 2 | $json = []; |
|
22 | 2 | $json['class'] = get_class($throwable); |
|
23 | 2 | $json['message'] = $throwable->getMessage(); |
|
24 | 2 | $json['code'] = $throwable->getCode(); |
|
25 | 2 | $json['file'] = $throwable->getFile(); |
|
26 | 2 | $json['line'] = $throwable->getLine(); |
|
27 | 2 | $json['trace'] = []; |
|
28 | 2 | foreach ($throwable->getTrace() as $item) { |
|
29 | 2 | $item['args'] = []; |
|
30 | 2 | $json['trace'][] = $item; |
|
31 | } |
||
32 | |||
33 | 2 | return $json; |
|
34 | } |
||
35 | |||
69 |