| @@ 153-156 (lines=4) @@ | ||
| 150 | public static function fromJson($jsonData) |
|
| 151 | { |
|
| 152 | $tokenData = json_decode($jsonData, true); |
|
| 153 | if (is_null($tokenData) && JSON_ERROR_NONE !== json_last_error()) { |
|
| 154 | $errorMsg = function_exists('json_last_error_msg') ? json_last_error_msg() : json_last_error(); |
|
| 155 | throw new RuntimeException(sprintf('unable to decode JSON: %s', $errorMsg)); |
|
| 156 | } |
|
| 157 | ||
| 158 | if (!is_array($tokenData)) { |
|
| 159 | throw new RuntimeException('JSON data MUST be an array'); |
|
| @@ 96-99 (lines=4) @@ | ||
| 93 | public function json() |
|
| 94 | { |
|
| 95 | $decodedJson = json_decode($this->responseBody, true); |
|
| 96 | if (is_null($decodedJson) && JSON_ERROR_NONE !== json_last_error()) { |
|
| 97 | $errorMsg = function_exists('json_last_error_msg') ? json_last_error_msg() : json_last_error(); |
|
| 98 | throw new RuntimeException(sprintf('unable to decode JSON: %s', $errorMsg)); |
|
| 99 | } |
|
| 100 | ||
| 101 | return $decodedJson; |
|
| 102 | } |
|