public function SiteAuditCheckCodebasePhpCopyPasteDetection::getResultWarn in Site Audit 8.2
Implements \SiteAudit\Check\Abstract\getResultWarn().
Overrides SiteAuditCheckAbstract::getResultWarn
File
- Check/
Codebase/ PhpCopyPasteDetection.php, line 55 - Contains \SiteAudit\Check\Codebase\PhpMessDetection.
Class
- SiteAuditCheckCodebasePhpCopyPasteDetection
- Class SiteAuditCheckCodebasePhpCopyPasteDetection.
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('File: Lines') . '</th></thead>';
foreach ($this->registry['phpcpd_out'] as $duplication) {
$lines = (int) $duplication['lines'];
$ret_val .= '<tr><td>';
foreach ($duplication->file as $file) {
$path = $this
->getRelativePath($file['path']);
$line_start = (int) $file['line'];
$line_end = $line_start + $lines;
$ret_val .= "{$path}: {$line_start}-{$line_end}<br>";
}
$ret_val .= '</tr></td>';
}
$ret_val .= '</table>';
}
else {
$ret_val .= 'Duplications: ' . count($this->registry['phpcpd_out']);
foreach ($this->registry['phpcpd_out'] as $duplication) {
$rows = 0;
$lines = (int) $duplication['lines'];
foreach ($duplication->file as $file) {
$ret_val .= PHP_EOL;
if ($rows++ == 0) {
$ret_val .= str_repeat(' ', 6) . '- ';
}
else {
if (!drush_get_option('json')) {
$ret_val .= str_repeat(' ', 8);
}
}
$path = $this
->getRelativePath((string) $file['path']);
$line_start = (int) $file['line'];
$line_end = $line_start + $lines;
$ret_val .= "{$path}: {$line_start}-{$line_end}";
}
}
}
return $ret_val;
}