| @@ 109-112 (lines=4) @@ | ||
| 106 | throw new ResponseException(sprintf('response MUST have JSON content type')); |
|
| 107 | } |
|
| 108 | $decodedJson = json_decode($this->responseBody, true); |
|
| 109 | if (is_null($decodedJson) && JSON_ERROR_NONE !== json_last_error()) { |
|
| 110 | $errorMsg = function_exists('json_last_error_msg') ? json_last_error_msg() : json_last_error(); |
|
| 111 | throw new ResponseException(sprintf('unable to decode JSON: %s', $errorMsg)); |
|
| 112 | } |
|
| 113 | ||
| 114 | return $decodedJson; |
|
| 115 | } |
|
| @@ 143-146 (lines=4) @@ | ||
| 140 | public static function fromStorage($tokenString) |
|
| 141 | { |
|
| 142 | $tokenData = json_decode($tokenString, true); |
|
| 143 | if (is_null($tokenData) && JSON_ERROR_NONE !== json_last_error()) { |
|
| 144 | $errorMsg = function_exists('json_last_error_msg') ? json_last_error_msg() : json_last_error(); |
|
| 145 | throw new AccessTokenException(sprintf('unable to decode JSON from storage: %s', $errorMsg)); |
|
| 146 | } |
|
| 147 | ||
| 148 | return new self($tokenData); |
|
| 149 | } |
|