/** * Creates an OAuth response. * * @param \Widop\HttpAdapter\HttpResponse $httpResponse The http response. * * @throws \InvalidArgumentException If the format is not supported. */ public function __construct(HttpResponse $httpResponse, $format = self::FORMAT_JSON) { $this->httpResponse = $httpResponse; $this->format = $format; if ($format === self::FORMAT_JSON) { $this->data = json_decode($httpResponse->getBody(), true); } else { if ($format === self::FORMAT_STR) { parse_str($httpResponse->getBody(), $this->data); } else { throw new \InvalidArgumentException(sprintf('The OAuth response format "%s" is not supported.', $format)); } } }
public function testBody() { $this->assertSame($this->body, $this->httpResponse->getBody()); }
/** * Parses & normalizes the Time Zone API response * * @param $response * @return array */ protected function parse(HttpResponse $response) { return json_decode($response->getBody(), true); }