@@ -181,20 +181,18 @@ private function request($method, $endpoint, $parameters = array(), $rawRequest
181181 $ err = json_decode ($ resultBody , true );
182182 if ($ err === NULL ) {
183183 $ jsonError = $ this ->json_error_to_string (json_last_error ());
184- if (! empty ( $ jsonError) )
184+ if ($ jsonError )
185185 {
186186 error_log (sprintf ('Error parsing response body JSON: %s ' , $ jsonError ));
187187 error_log (sprintf ('Response body: %s ' , $ result ->getBody ()));
188188 throw new ToopherRequestException (sprintf ('JSON Parsing Error: %s ' , $ jsonError ));
189189 }
190190 }
191-
192191 if (array_key_exists ('error_message ' , $ err ))
193192 {
194193 throw new ToopherRequestException ($ err ['error_message ' ], $ err ['error_code ' ]);
195- } else {
196- throw new ToopherRequestException (sprintf ('%s - %s ' , $ result ->getReasonPhrase (), $ resultBody ), $ result ->getStatus ());
197194 }
195+ throw new ToopherRequestException (sprintf ('%s - %s ' , $ result ->getReasonPhrase (), $ resultBody ), $ result ->getStatus ());
198196 }
199197
200198 if ($ rawRequest ) {
@@ -203,14 +201,14 @@ private function request($method, $endpoint, $parameters = array(), $rawRequest
203201 $ decoded = json_decode ($ resultBody , true );
204202 if ($ decoded === NULL ) {
205203 $ jsonError = $ this ->json_error_to_string (json_last_error ());
206- if (! empty ( $ jsonError) )
204+ if ($ jsonError )
207205 {
208206 error_log (sprintf ('Error parsing response body JSON: %s ' , $ jsonError ));
209207 error_log (sprintf ('Response body: %s ' , $ result ->getBody ()));
210208 throw new ToopherRequestException (sprintf ('JSON Parsing Error: %s ' , $ jsonError ));
211209 }
212210 }
213- return $ decoded ;
211+ return $ decoded ;
214212 }
215213 }
216214
0 commit comments