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