public function parse(Header $header, $htmlValidatorBodyContent) { $body = new Body(); switch ($header->get('content-type')->getTypeSubtypeString()) { case 'application/json': $applicationJsonParser = new ApplicationJsonParser(); $applicationJsonParser->setConfiguration($this->getConfiguration()); $body->setContent($applicationJsonParser->parse($htmlValidatorBodyContent)); break; case 'text/html': $textHtmlParser = new TextHtmlBodyParser(); $body->setContent($textHtmlParser->parse($htmlValidatorBodyContent)); break; default: throw new \InvalidArgumentException('Invalid content type: ' . $header->get('content-type')->getTypeSubtypeString(), 1); } return $body; }