/** * Return a response instance from a PSR-7 Response message. */ public static function fromHttpResponse(ResponseInterface $response) { // Decode the body for the returned data. $data = Helper::parseBody($response); // Get the HTTP status. $httpCode = $response->getStatusCode(); $httpReason = $response->getReasonPhrase(); // Return the response object. return static::fromData($data, $httpCode); }
/** * Parse the body of a PSR-7 message, into a PHP array. * TODO: if this message is a ServerRequestInterface, then the parsed body may already * be available through getParsedBody() - check that first. Maybe even move that check to * AbstractServerRequest and fall back to this (the parent) if not set. * @param $message MessageInterface * @return array|mixed */ public static function parseBody(MessageInterface $message) { return Helper::parseBody($message); }