Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit 7b35ef7

Browse files
committed
Merge branch 'hotfix/14-payload-from-xml-response'
Fixes #14
2 parents 4e76096 + 5621e24 commit 7b35ef7

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

test/ProblemDetailsAssertionsTrait.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,21 @@ public function getPayloadFromXmlResponse(ResponseInterface $response) : array
7878
$body = $response->getBody();
7979
$xml = simplexml_load_string((string) $body);
8080
$json = json_encode($xml);
81-
return json_decode($json, true);
81+
$payload = json_decode($json, true);
82+
83+
// Ensure ints and floats are properly represented
84+
array_walk_recursive($payload, function (&$item) {
85+
if ((string) (int) $item === $item) {
86+
$item = (int) $item;
87+
return;
88+
}
89+
90+
if ((string) (float) $item === $item) {
91+
$item = (float) $item;
92+
return;
93+
}
94+
});
95+
96+
return $payload;
8297
}
8398
}

0 commit comments

Comments
 (0)