Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 public function generate(ReportSummary $reportSummary)
 {
     $dom = new \DOMDocument('1.0', 'UTF-8');
     // new nodes should be added to this or existing children
     $root = $dom->createElement('report');
     $dom->appendChild($root);
     $filesXML = $dom->createElement('files');
     $root->appendChild($filesXML);
     $i = 1;
     foreach ($reportSummary->getChanged() as $file => $fixResult) {
         $fileXML = $dom->createElement('file');
         $fileXML->setAttribute('id', $i++);
         $fileXML->setAttribute('name', $file);
         $filesXML->appendChild($fileXML);
         if ($reportSummary->shouldAddAppliedFixers()) {
             $fileXML->appendChild($this->createAppliedFixersElement($dom, $fixResult));
         }
         if (!empty($fixResult['diff'])) {
             $fileXML->appendChild($this->createDiffElement($dom, $fixResult));
         }
     }
     if (null !== $reportSummary->getTime()) {
         $root->appendChild($this->createTimeElement($reportSummary->getTime(), $dom));
     }
     if (null !== $reportSummary->getTime()) {
         $root->appendChild($this->createMemoryElement($reportSummary->getMemory(), $dom));
     }
     $dom->formatOutput = true;
     return $dom->saveXML();
 }
Esempio n. 2
0
 /**
  * {@inheritdoc}
  */
 public function generate(ReportSummary $reportSummary)
 {
     $jFiles = array();
     foreach ($reportSummary->getChanged() as $file => $fixResult) {
         $jfile = array('name' => $file);
         if ($reportSummary->shouldAddAppliedFixers()) {
             $jfile['appliedFixers'] = $fixResult['appliedFixers'];
         }
         if (!empty($fixResult['diff'])) {
             $jfile['diff'] = $fixResult['diff'];
         }
         $jFiles[] = $jfile;
     }
     $json = array('files' => $jFiles);
     if (null !== $reportSummary->getTime()) {
         $json['time'] = array('total' => round($reportSummary->getTime() / 1000, 3));
     }
     if (null !== $reportSummary->getMemory()) {
         $json['memory'] = round($reportSummary->getMemory() / 1024 / 1024, 3);
     }
     return json_encode($json);
 }
Esempio n. 3
0
 /**
  * {@inheritdoc}
  */
 public function generate(ReportSummary $reportSummary)
 {
     $output = '';
     $i = 0;
     foreach ($reportSummary->getChanged() as $file => $fixResult) {
         ++$i;
         $output .= sprintf('%4d) %s', $i, $file);
         if ($reportSummary->shouldAddAppliedFixers()) {
             $output .= $this->getAppliedFixers($reportSummary->isDecoratedOutput(), $fixResult);
         }
         $output .= $this->getDiff($reportSummary->isDecoratedOutput(), $fixResult);
         $output .= PHP_EOL;
     }
     $output .= $this->getFooter($reportSummary->getTime(), $reportSummary->getMemory(), $reportSummary->isDryRun());
     return $output;
 }