Skip to content
This repository has been archived by the owner on Oct 22, 2021. It is now read-only.

Commit

Permalink
added type check for Client\getErrorMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
thellimist committed Jul 29, 2016
1 parent 948ca1d commit cd704ee
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/API/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace CF\API;

use GuzzleHttp\Exception\RequestException;

class Client extends AbstractAPIClient
{
const CLIENT_API_NAME = 'CLIENT API';
Expand Down Expand Up @@ -49,14 +51,15 @@ public function createAPIError($message)
}

/**
* @param RequestException object
* @param RequestException error
*
* @return string
*/
public function getErrorMessage($error)
public function getErrorMessage(RequestException $error)
{
$jsonResponse = json_decode($error->getResponse()->getBody(), true);
$errorMessage = $error->getMessage();

if (count($jsonResponse['errors']) > 0) {
$errorMessage = $jsonResponse['errors'][0]['message'];
}
Expand Down

0 comments on commit cd704ee

Please sign in to comment.