private function getFromHtml5Pattern($htmlErrorString, $pattern) { if ($this->matches($htmlErrorString, $pattern)) { $matches = $this->preg_match($htmlErrorString, $pattern); if ($matches === false) { return false; } $parameters = $this->getParametersFromMatchString($matches[0], $pattern); $normalisedError = new NormalisedError(); $normalisedError->setNormalForm($this->getNormalForm($pattern)); foreach ($parameters as $parameter) { $normalisedError->addParameter($parameter); } return $normalisedError; } return false; }
private function processSpecialCase($htmlErrorString) { if (substr_count($htmlErrorString, 'I am unable to validate this document')) { $normalForm = 'Unable to interpret %0 as %1 on line %2'; $normalisedError = new NormalisedError(); $normalisedError->setNormalForm($normalForm); $byteMatches = array(); preg_match('/".+"/', $htmlErrorString, $byteMatches); $normalisedError->addParameter($byteMatches[0]); $encodingMatches = array(); preg_match('/<code>.+<\\/code>/', $htmlErrorString, $encodingMatches); $normalisedError->addParameter(str_replace(array('<code>', '</code>'), '', $encodingMatches[0])); $lineMatches = array(); preg_match('/<strong>[0-9]+<\\/strong>/', $htmlErrorString, $lineMatches); $normalisedError->addParameter(str_replace(array('<strong>', '</strong>'), '', $lineMatches[0])); return $normalisedError; } return false; }