public function __construct(RequestInterface $pRequest) { /** url parsing "formula" for resource */ list(, $subscription, $format, , $season, $week) = explode('/', $pRequest->getPath()); $file_partial = __DIR__ . '/' . implode('.', [$subscription, $format, $season, $week]); $headers = (include $file_partial . '.header.php'); $response_code = explode(' ', $headers[0])[1]; $mocked_response = file_get_contents($file_partial . '.body.' . $format); $stream = Stream\Stream::factory($mocked_response); parent::__construct($response_code, $headers, $stream); }
/** * @param \GuzzleHttp\Message\Response $response */ function __construct($response) { parent::__construct($response->getStatusCode(), $response->getHeaders(), $response->getBody()); $jsonBody = $this->json(); if (array_key_exists("code", $jsonBody)) { $this->internal_code = $jsonBody["code"]; $this->internal_message = $jsonBody["message"]; $this->internal_type = $jsonBody["type"]; } if (array_key_exists("atoken", $jsonBody) || array_key_exists("uid", $jsonBody)) { $this->internal_code = 200; $this->internal_type = $jsonBody["type"] = "oauthResponse"; } }
/** * @param int|string $statusCode The response status code (e.g. 200) * @param array $headers The response headers * @param StreamInterface $body The body of the response * @param array $options Response message options * - reason_phrase: Set a custom reason phrase * - protocol_version: Set a custom protocol version */ public function __construct($statusCode, array $headers = [], StreamInterface $body = null, array $options = []) { parent::__construct($statusCode, $headers, $body, $options); }