Пример #1
0
 /**
  * @param Result $result
  * @return string
  */
 public function format(Result $result)
 {
     $issues = ResultHelper::sortIssues($result->getIssues());
     $metrics = ResultHelper::sortMetrics($result->getMetrics());
     $markdown = new MarkdownBuilder();
     $markdown->h1(count($issues) . ' Issue(s)');
     foreach (ResultHelper::groupIssues($issues) as $file => $issues) {
         $this->renderSection($markdown, $file, $issues);
     }
     $markdown->h1(count($metrics) . ' Metric(s)');
     foreach ($metrics as $metric) {
         $this->renderMetric($markdown, $metric);
     }
     return $markdown->getMarkdown();
 }
Пример #2
0
 /**
  * @param Result $result
  * @return string
  */
 public function format(Result $result)
 {
     $issues = ResultHelper::sortIssues($result->getIssues());
     $metrics = ResultHelper::sortMetrics($result->getMetrics());
     $markdown = new MarkdownBuilder();
     $markdown->h1(count($issues) . ' Issue(s)');
     $markdown->bulletedList(array_map(function (Issue $issue) {
         return sprintf('%s on line %s: %s', $issue->getFile(), $issue->getLine(), $issue->getTitle());
     }, $issues));
     $metrics = array_filter($metrics, function (Metric $metric) {
         return $metric->getValue() != 0;
     });
     $markdown->h1(count($metrics) . ' Metric(s)');
     $markdown->bulletedList(array_map(function (Metric $metric) {
         return sprintf('[%s] %s: %s', $metric->getCode(), $metric->getTitle(), $metric->getValue());
     }, $metrics));
     return $markdown->getMarkdown();
 }
Пример #3
0
 /**
  * @param AnalyseResult $from
  * @param AnalyseResult $to
  * @param Result $result
  */
 private function prepareMetricDiff(AnalyseResult $from, AnalyseResult $to, Result $result)
 {
     $fromMetrics = $this->createMetricsHashMap($from->getMetrics());
     $toMetrics = $this->createMetricsHashMap($to->getMetrics());
     foreach ($toMetrics as $hash => $toMetric) {
         if (!isset($fromMetrics[$hash])) {
             continue;
         }
         $fromMetric = $fromMetrics[$hash];
         if ($fromMetric->getValue() == $toMetric->getValue()) {
             continue;
         }
         $metric = new Metric();
         $metric->from = $fromMetric;
         $metric->to = $toMetric;
         $metric->diff = $toMetric->getValue() - $fromMetric->getValue();
         $result->metricChanges[] = $metric;
     }
 }