Conditions | 3 |
Paths | 3 |
Total Lines | 11 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php declare(strict_types=1); |
||
28 | public function from(RestResource $resource): string |
||
29 | { |
||
30 | try { |
||
31 | $result = json_encode($this->prepare($resource)); |
||
32 | } catch (Throwable $exception) { |
||
33 | throw CannotFormatJson::because($resource, $exception); |
||
34 | } |
||
35 | if (!is_string($result)) { |
||
|
|||
36 | throw CannotFormatJson::jsonError($resource, json_last_error_msg()); |
||
37 | } |
||
38 | return $result; |
||
39 | } |
||
59 |