/** * {@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(); }
/** * {@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; }
/** * {@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); }
<?php require_once 'ReportSummary.php'; $tracking = new ReportSummary(); $date = isset($argv[1]) ? $argv[1] : ''; $hour = isset($argv[2]) ? $argv[2] : ''; if ('' != $date) { if ('' != $hour) { $created_h = strtotime("{$date} {$hour}:00:00"); if ($rows = $tracking->updateReportHour($created_h)) { echo "Report Success: " . $rows; } else { echo "No Report Complete"; } } else { $created = strtotime($date); if ($rows = $tracking->updateReportDay($created)) { echo "Report Success: " . $rows; } else { echo "No Report Complete"; } } }