public function __invoke(Context $context, $next) { if (isset($this->options['allowedMethods'][$context->getMethod()])) { $contentType = $context->getRequest()->getContentType(); if (!isset($this->parsers[$contentType])) { throw new \Exception('Cannot found parser for ' . $contentType); } $parser = $this->parsers[$contentType]; $context = $parser($context); } $next($context); }