Skip to content

Commit c116afa

Browse files
committed
:octocat: get_json() & get_xml(): allow MessageInterface
1 parent edf5c22 commit c116afa

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/Psr7/message_helpers.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -393,29 +393,29 @@ function normalize_nested_file_spec(array $files = []):array{
393393
}
394394

395395
/**
396-
* @param \Psr\Http\Message\ResponseInterface $response
397-
* @param bool|null $assoc
396+
* @param \Psr\Http\Message\MessageInterface $message
397+
* @param bool|null $assoc
398398
*
399399
* @return \stdClass|array|bool
400400
*/
401-
function get_json(ResponseInterface $response, bool $assoc = null){
402-
$data = json_decode($response->getBody()->__toString(), $assoc);
401+
function get_json(MessageInterface $message, bool $assoc = null){
402+
$data = json_decode($message->getBody()->__toString(), $assoc);
403403

404-
$response->getBody()->rewind();
404+
$message->getBody()->rewind();
405405

406406
return $data;
407407
}
408408

409409
/**
410-
* @param \Psr\Http\Message\ResponseInterface $response
411-
* @param bool|null $assoc
410+
* @param \Psr\Http\Message\MessageInterface $message
411+
* @param bool|null $assoc
412412
*
413413
* @return \SimpleXMLElement|array|bool
414414
*/
415-
function get_xml(ResponseInterface $response, bool $assoc = null){
416-
$data = simplexml_load_string($response->getBody()->__toString());
415+
function get_xml(MessageInterface $message, bool $assoc = null){
416+
$data = simplexml_load_string($message->getBody()->__toString());
417417

418-
$response->getBody()->rewind();
418+
$message->getBody()->rewind();
419419

420420
return $assoc === true
421421
? json_decode(json_encode($data), true) // cruel

0 commit comments

Comments
 (0)