SensioLabs\Insight\Sdk\Model\Analysis::getViolations PHP Method

getViolations() public method

public getViolations ( ) : Violations | null
return Violations | null
    public function getViolations()
    {
        return $this->violations;
    }

Usage Example

Example #1
0
 protected function describeAnalysis(Analysis $analysis, array $options = array())
 {
     $output = $options['output'];
     $xml = new \DOMDocument('1.0', 'UTF-8');
     $xpath = new \DOMXPath($xml);
     $xml->formatOutput = true;
     $xml->preserveWhiteSpace = true;
     $pmd = $xml->createElement('pmd');
     $pmd->setAttribute('timestamp', $analysis->getEndAt()->format('c'));
     $xml->appendChild($pmd);
     foreach ($analysis->getViolations() as $violation) {
         /**
          * @var $violation \SensioLabs\Insight\Sdk\Model\Violation
          */
         $filename = $violation->getResource();
         $nodes = $xpath->query(sprintf('//file[@name="%s"]', $filename));
         if ($nodes->length > 0) {
             $node = $nodes->item(0);
         } else {
             $node = $xml->createElement('file');
             $node->setAttribute('name', $filename);
             $pmd->appendChild($node);
         }
         $violationNode = $xml->createElement('violation', $violation->getMessage());
         $node->appendChild($violationNode);
         $violationNode->setAttribute('beginline', $violation->getLine());
         $violationNode->setAttribute('endline', $violation->getLine());
         $violationNode->setAttribute('rule', $violation->getTitle());
         $violationNode->setAttribute('ruleset', $violation->getCategory());
         $violationNode->setAttribute('priority', $this->getPriority($violation));
     }
     $output->writeln($xml->saveXML());
 }
All Usage Examples Of SensioLabs\Insight\Sdk\Model\Analysis::getViolations