Skip to content

Commit 88c9a1a

Browse files
committed
:octocat: +Psr7\get_xml() param $assoc
1 parent 88d2fe7 commit 88c9a1a

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/Psr7/message_helpers.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -396,14 +396,19 @@ function get_json(ResponseInterface $response, bool $assoc = null){
396396
}
397397

398398
/**
399-
* @todo
400-
*
401399
* @param \Psr\Http\Message\ResponseInterface $response
400+
* @param bool|null $assoc
402401
*
403402
* @return \SimpleXMLElement
403+
* @todo
404+
*
404405
*/
405-
function get_xml(ResponseInterface $response){
406-
return simplexml_load_string($response->getBody()->getContents());
406+
function get_xml(ResponseInterface $response, bool $assoc = null){
407+
$data = simplexml_load_string($response->getBody()->getContents());
408+
409+
return $assoc === true
410+
? json_decode(json_encode($data), true) // cruel
411+
: $data;
407412
}
408413

409414
/**

0 commit comments

Comments
 (0)