/**
  * Render the whole report to html.
  *
  * @param SimpleXMLElement $xml structure containing all the information to be rendered.
  * @param int $numerrors total number of error-level violations in the run.
  * @param int $numwarnings total number of warning-level violations in the run.
  * @return string the report html
  */
 public function report(SimpleXMLElement $xml, $numerrors, $numwarnings)
 {
     $grandsummary = '';
     $grandtype = '';
     if ($numerrors + $numwarnings > 0) {
         $grandsummary = get_string('numerrorswarnings', 'local_codechecker', array('errors' => $numerrors, 'warnings' => $numwarnings));
         if ($numerrors) {
             $grandtype = 'fail error';
         } else {
             $grandtype = 'fail warning';
         }
     }
     // Output begins.
     $output = '';
     $output .= html_writer::start_tag('div', array('class' => 'local_codechecker_results'));
     // Sort the file by path.
     $files = $xml->xpath('file');
     $sortedfiles = array();
     foreach ($files as $fileinxml) {
         $sortedfiles[local_codechecker_pretty_path($fileinxml['name'])] = $fileinxml;
     }
     ksort($sortedfiles);
     $files = $sortedfiles;
     // Files count and list.
     $numfiles = count($files);
     $output .= $this->summary_start($numfiles);
     // Heading summaries.
     $index = 0;
     foreach ($files as $prettypath => $fileinxml) {
         $index++;
         $summary = '';
         if ($fileinxml['errors'] + $fileinxml['warnings'] > 0) {
             $numerrwarn = (object) array('errors' => "{$fileinxml['errors']}", 'warnings' => "{$fileinxml['warnings']}");
             $summary = get_string('numerrorswarnings', 'local_codechecker', $numerrwarn);
         }
         $output .= $this->summary_line($index, $prettypath, $summary);
     }
     $output .= $this->summary_end($numfiles, $grandsummary, $grandtype);
     // Details.
     $index = 0;
     foreach ($files as $prettypath => $fileinxml) {
         $index++;
         if ($fileinxml['errors'] + $fileinxml['warnings'] == 0) {
             continue;
         }
         $output .= $this->problems($index, $fileinxml, $prettypath);
     }
     $output .= html_writer::end_tag('div');
     return $output;
 }
 public function report(array $problems, PHP_CodeSniffer $phpcs, $totalproblems)
 {
     $output = '';
     $numfiles = count($problems);
     $output .= $this->summary_start($numfiles);
     $index = 0;
     foreach ($problems as $file => $info) {
         $index++;
         $summary = '';
         if ($info['numErrors'] + $info['numWarnings'] > 0) {
             $summary = get_string('numerrorswarnings', 'local_codechecker', $info);
         }
         $output .= $this->summary_line($index, local_codechecker_pretty_path($file), $summary);
     }
     $output .= $this->summary_end($numfiles, $totalproblems);
     $index = 0;
     foreach ($problems as $file => $info) {
         $index++;
         if ($info['numErrors'] + $info['numWarnings'] == 0) {
             continue;
         }
         $output .= $this->problems($index, local_codechecker_pretty_path($file), $info);
     }
     return $output;
 }