Conditions | 3 |
Paths | 3 |
Total Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 3 |
Changes | 0 |
1 | <?php |
||
15 | 58 | public function jsonSerialize() |
|
16 | { |
||
17 | 58 | $contents = (string) $this->getContents(); |
|
18 | 58 | if ($contents === '') { |
|
19 | 1 | return null; |
|
20 | } |
||
21 | 57 | $decodedContents = json_decode($contents, true); |
|
22 | 57 | if (json_last_error() !== JSON_ERROR_NONE) { |
|
23 | 1 | throw new \RuntimeException( |
|
24 | 'Error trying to decode response: ' . |
||
25 | 1 | json_last_error_msg() |
|
26 | ); |
||
27 | } |
||
28 | |||
29 | 56 | return $decodedContents; |
|
30 | } |
||
31 | } |