Example #1
0
 /**
  * @param AnalyseResult $from
  * @param AnalyseResult $to
  * @param Result $result
  */
 private function prepareIssueDiff(AnalyseResult $from, AnalyseResult $to, Result $result)
 {
     $fromIssues = $this->createIssuesHashMap($from->getIssues());
     $toIssues = $this->createIssuesHashMap($to->getIssues());
     foreach ($toIssues as $hash => $issue) {
         if (isset($fromIssues[$hash])) {
             unset($fromIssues[$hash]);
             continue;
         }
         $result->newIssues[] = $issue;
     }
     $result->resolvedIssues = array_values($fromIssues);
 }
Example #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)');
     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();
 }
Example #3
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();
 }