public function parse($htmlValidatorHeaderContent) { $header = new Header(); $headerLines = explode("\n", $htmlValidatorHeaderContent); foreach ($headerLines as $headerLine) { $keyValueParts = explode(':', $headerLine, 2); if ($this->isContentTypeHeader($keyValueParts[0])) { $mediaTypeParser = new MediaTypeParser(); $header->set($keyValueParts[0], $mediaTypeParser->parse($keyValueParts[1])); } if ($this->isW3cValidatorHeaderKey($keyValueParts[0])) { $header->set($this->getKeyFromW3cKey($keyValueParts[0]), $this->getTypedValueFromW3cValue(trim($keyValueParts[1]))); } } return $header; }
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; }
/** * * @return boolean */ public function wasAborted() { $status = $this->header->get('status'); return is_null($status) || $status == self::STATUS_ABORT; }