/**
  * 
  * @param array $properties
  * @return \webignition\CssValidatorOutput\Parser\Parser
  */
 protected function getParser($properties)
 {
     $configuration = new Configuration();
     $configuration->setRawOutput($properties['rawOutput']);
     if (isset($properties['configuration'])) {
         foreach ($properties['configuration'] as $key => $value) {
             $methodName = 'set' . $key;
             $configuration->{$methodName}($value);
         }
     }
     $parser = new CssValidatorOutputParser();
     $parser->setConfiguration($configuration);
     return $parser;
 }
 /**
  * 
  * @return \webignition\CssValidatorOutput\CssValidatorOutput
  * @throws \InvalidArgumentException
  */
 public function validate()
 {
     if (!$this->hasConfiguration()) {
         throw new \InvalidArgumentException('Unable to validate; configuration not set', self::INVALID_ARGUMENT_EXCEPTION_CONFIGURATION_NOT_SET);
     }
     try {
         $this->getLocalProxyResource()->prepare();
     } catch (\webignition\WebResource\Exception\InvalidContentTypeException $invalidContentTypeException) {
         $cssValidatorOutput = new CssValidatorOutput();
         $cssValidatorOutputException = new ExceptionOutput();
         $cssValidatorOutputException->setType(new ExceptionOutputType('invalid-content-type:' . $invalidContentTypeException->getResponseContentType()->getTypeSubtypeString()));
         $cssValidatorOutput->setException($cssValidatorOutputException);
         return $cssValidatorOutput;
     } catch (\webignition\WebResource\Exception\Exception $webResourceException) {
         $cssValidatorOutput = new CssValidatorOutput();
         $cssValidatorOutputException = new ExceptionOutput();
         $cssValidatorOutputException->setType(new ExceptionOutputType('http' . $webResourceException->getResponse()->getStatusCode()));
         $cssValidatorOutput->setException($cssValidatorOutputException);
         return $cssValidatorOutput;
     } catch (ConnectException $connectException) {
         $curlExceptionFactory = new CurlExceptionFactory();
         if ($curlExceptionFactory->isCurlException($connectException)) {
             $curlException = $curlExceptionFactory->fromConnectException($connectException);
             $cssValidatorOutput = new CssValidatorOutput();
             $cssValidatorOutputException = new ExceptionOutput();
             $cssValidatorOutputException->setType(new ExceptionOutputType('curl' . $curlException->getCurlCode()));
             $cssValidatorOutput->setException($cssValidatorOutputException);
             return $cssValidatorOutput;
         }
     }
     $cssValidatorOutputParserConfiguration = new CssValidatorOutputParserConfiguration();
     $validatorOutput = $this->replaceLocalFilePathsWithOriginalFilePaths(implode("\n", $this->getRawValidatorOutputLines()));
     $cssValidatorOutputParserConfiguration->setRawOutput($validatorOutput);
     $this->localProxyResource->clear();
     if ($this->getConfiguration()->hasFlag(Flags::FLAG_IGNORE_FALSE_IMAGE_DATA_URL_MESSAGES)) {
         $cssValidatorOutputParserConfiguration->setIgnoreFalseImageDataUrlMessages(true);
     }
     if ($this->getConfiguration()->hasFlag(Flags::FLAG_IGNORE_WARNINGS)) {
         $cssValidatorOutputParserConfiguration->setIgnoreWarnings(true);
     }
     if ($this->getConfiguration()->getVendorExtensionSeverityLevel() === VendorExtensionSeverityLevel::LEVEL_IGNORE) {
         $cssValidatorOutputParserConfiguration->setIgnoreVendorExtensionIssues(true);
     }
     if ($this->getConfiguration()->getVendorExtensionSeverityLevel() === VendorExtensionSeverityLevel::LEVEL_WARN) {
         $cssValidatorOutputParserConfiguration->setReportVendorExtensionIssuesAsWarnings(true);
     }
     if ($this->getConfiguration()->hasDomainsToIgnore()) {
         $cssValidatorOutputParserConfiguration->setRefDomainsToIgnore($this->getConfiguration()->getDomainsToIgnore());
     }
     $cssValidatorOutputParser = new CssValidatorOutputParser();
     $cssValidatorOutputParser->setConfiguration($cssValidatorOutputParserConfiguration);
     $output = $cssValidatorOutputParser->getOutput();
     if ($this->getLocalProxyResource()->hasWebResourceExceptions()) {
         foreach ($this->getLocalProxyResource()->getWebResourceExceptions() as $webResourceException) {
             $error = new \webignition\CssValidatorOutput\Message\Error();
             $error->setContext('');
             $error->setLineNumber(0);
             if ($webResourceException instanceof \webignition\WebResource\Exception\InvalidContentTypeException) {
                 $error->setMessage('invalid-content-type:' . (string) $webResourceException->getResponseContentType());
             } else {
                 $error->setMessage('http-error:' . $webResourceException->getResponse()->getStatusCode());
             }
             $error->setRef($webResourceException->getRequest()->getUrl());
             $output->addMessage($error);
         }
     }
     if ($this->getLocalProxyResource()->hasCurlExceptions()) {
         foreach ($this->getLocalProxyResource()->getCurlExceptions() as $curlExceptionDetails) {
             $error = new \webignition\CssValidatorOutput\Message\Error();
             $error->setContext('');
             $error->setLineNumber(0);
             $error->setMessage('curl-error:' . $curlExceptionDetails['exception']->getCurlCode());
             $error->setRef($curlExceptionDetails['url']);
             $output->addMessage($error);
         }
     }
     return $cssValidatorOutputParser->getOutput();
 }