Skip to content

Commit

Permalink
Fix warning in ResponseMediator when $content is not an array (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmleroux authored and cdaguerre committed Aug 26, 2016
1 parent cec1728 commit 1c20ded
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/Textmaster/HttpClient/Message/ResponseMediator.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static function getContent(Response $response)
&& strpos($response->getHeader('Content-Type')[0], 'application/json') === 0
) {
$content = json_decode($body->getContents(), true);
if (array_key_exists('errors', $content)) {
if (is_array($content) && array_key_exists('errors', $content)) {
self::createException($response);
}

Expand All @@ -55,7 +55,7 @@ public static function getContent(Response $response)
protected static function createException(Response $response)
{
$content = json_decode($response->getBody()->getContents(), true);
if (array_key_exists('errors', $content)) {
if (is_array($content) && array_key_exists('errors', $content)) {
$message = json_encode($content['errors'], JSON_UNESCAPED_UNICODE);
} else {
$message = $response->getReasonPhrase();
Expand Down

0 comments on commit 1c20ded

Please sign in to comment.