/**
  * Return the response body as a PHP array
  *
  * @return array
  **/
 protected function getResponseBody()
 {
     try {
         return $this->response->json();
     } catch (\Exception $e) {
         $this->responseErrors['json'] = $e->getMessage();
         return [];
     }
 }
 /**
  * {@inheritDoc}
  *
  * @internal The current user endpoint gives a redirection, so we need to
  *     override the HTTP call to avoid redirections.
  */
 protected function fetchUserDetails(TokenCredentials $tokenCredentials, $force = true)
 {
     if (!$this->cachedUserDetailsResponse || $force) {
         try {
             $this->request($this->urlUserDetails(), $tokenCredentials, array('options' => array('allow_redirects' => false)));
         } catch (BadResponseException $e) {
             throw new \Exception($e->getMessage());
         }
         switch ($this->responseType) {
             case 'json':
                 $this->cachedUserDetailsResponse = $this->response->json();
                 break;
             case 'xml':
                 $this->cachedUserDetailsResponse = $this->response->xml();
                 break;
             case 'string':
                 parse_str($this->response->getBody(), $this->cachedUserDetailsResponse);
                 break;
             default:
                 throw new \InvalidArgumentException("Invalid response type [{$this->responseType}].");
         }
     }
     return $this->cachedUserDetailsResponse;
 }
 /**
  * Output
  *
  * @param  Guzzle\Http\Message\Response $response Guzzle response object
  * @param  boolean $body
  * @return Array|Guzzle\Http\Message\Response Guzzle response body|object
  */
 protected function output($response, $body)
 {
     return $body ? $response->json() : $response;
 }