private function body(ServerRequestInterface $request)
{
$body = $request->getParsedBody();
if (empty($body)) {
return [];
}
if (is_object($body)) {
// Because the parsed body may also be represented as an object,
// additional parsing is required. This is a bit dirty but works
// very well for anonymous objects.
$body = json_decode(json_encode($body), true);
}
return $body;
}