Conditions | 5 |
Paths | 4 |
Total Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
28 | public function transform($value): string |
||
29 | { |
||
30 | if (method_exists($value, 'toJson')) { |
||
31 | return $value->toJson(); |
||
32 | } |
||
33 | |||
34 | if ($value instanceof JsonSerializable || $value instanceof StdClass) { |
||
|
|||
35 | return json_encode($value); |
||
36 | } |
||
37 | |||
38 | if (! method_exists($value, '__toString')) { |
||
39 | throw Untransformable::cannotTransformObject($value); |
||
40 | } |
||
41 | |||
42 | return "'{$value}'"; |
||
43 | } |
||
44 | } |
||
45 |