You are here

public function SiteAuditCheckCodebasePhpCodeSniffer::getResultWarn in Site Audit 8.2

Implements \SiteAudit\Check\Abstract\getResultWarn().

Overrides SiteAuditCheckAbstract::getResultWarn

File

Check/Codebase/PhpCodeSniffer.php, line 58
Contains \SiteAudit\Check\Codebase\PhpCodeSniffer.

Class

SiteAuditCheckCodebasePhpCodeSniffer
Class SiteAuditCheckCodebasePhpCodeSniffer.

Code

public function getResultWarn() {
  $ret_val = '';
  if (drush_get_option('html') == TRUE) {
    $ret_val .= '<table class="table table-condensed">';
    $ret_val .= '<thead><tr><th>' . dt('Line, Column') . '</th><th>' . dt('Severity') . '</th><th>' . dt('Action') . '</th></tr></thead>';
    foreach ($this->registry['phpcs_out'] as $filename => $violations) {
      $num_violations = count($violations);
      $ret_val .= "<tr align='center'><td colspan='3'>File: {$filename} Violations: {$num_violations}</td></tr>";
      foreach ($violations as $violation) {
        $line = $violation['line'];
        $column = $violation['column'];
        $severity = $violation['severity'];
        $message = $violation['message'];
        $ret_val .= "<tr><td>Line {$line}, Column {$column}</td><td>{$severity}</td><td>{$message}</td></tr>";
      }
    }
    $ret_val .= '</table>';
  }
  else {
    $rows = 0;
    foreach ($this->registry['phpcs_out'] as $filename => $violations) {
      if ($rows++ > 0) {
        $ret_val .= PHP_EOL;
        if (!drush_get_option('json')) {
          $ret_val .= str_repeat(' ', 4);
        }
      }
      $ret_val .= dt('Filename: @filename, Violations: @total', array(
        '@filename' => $filename,
        '@total' => count($violations),
      ));
      foreach ($violations as $violation) {
        $ret_val .= PHP_EOL;
        if (!drush_get_option('json')) {
          $ret_val .= str_repeat(' ', 6);
        }
        $ret_val .= 'Line ' . $violation['line'] . ', Column ' . $violation['column'] . ': ';
        $ret_val .= $violation['severity'] . ' - ' . $violation['message'];
      }
    }
  }
  return $ret_val;
}