| Conditions | 5 |
| Paths | 4 |
| Total Lines | 16 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 23 | public function transform($value) |
||
| 24 | { |
||
| 25 | if (method_exists($value, 'toJson')) { |
||
| 26 | return $value->toJson(); |
||
| 27 | } |
||
| 28 | |||
| 29 | if ($value instanceof JsonSerializable || $value instanceof StdClass) { |
||
| 30 | return json_encode($value); |
||
| 31 | } |
||
| 32 | |||
| 33 | if (!method_exists($value, '__toString')) { |
||
| 34 | throw new Exception('Cannot transform this object to JavaScript.'); |
||
| 35 | } |
||
| 36 | |||
| 37 | return "'{$value}'"; |
||
| 38 | } |
||
| 39 | } |
||
| 40 |