logger = $c->logger; } public function __invoke(Request $req, Response $res, callable $next) { if (($req->isPost() || $req->isPut() || $req->isPatch()) && $req->getParsedBody() == null) { $this->logger->warning('Got empty body in request with method ' . $req->getMethod()); return $res->withJson(['error' => 'The supplied body was empty'], 400); } else { return $next($req, $res); } } }