| Conditions | 3 |
| Paths | 3 |
| Total Lines | 16 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 3 |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 18 | 61 | #[\ReturnTypeWillChange] |
|
| 19 | public function jsonSerialize() |
||
| 20 | { |
||
| 21 | 61 | $contents = (string) $this->getContents(); |
|
| 22 | 61 | if ($contents === '') { |
|
| 23 | 1 | return null; |
|
| 24 | } |
||
| 25 | 60 | $decodedContents = json_decode($contents, true); |
|
| 26 | 60 | if (json_last_error() !== JSON_ERROR_NONE) { |
|
| 27 | 1 | throw new \RuntimeException( |
|
| 28 | 1 | 'Error trying to decode response: ' . |
|
| 29 | 1 | json_last_error_msg() |
|
| 30 | 1 | ); |
|
| 31 | } |
||
| 32 | |||
| 33 | 59 | return $decodedContents; |
|
| 34 | } |
||
| 35 | } |