public function SiteAuditCheckCodebasePhpLOC::getResultInfo in Site Audit 8.2
Implements \SiteAudit\Check\Abstract\getResultInfo().
Overrides SiteAuditCheckAbstract::getResultInfo
File
- Check/
Codebase/ PhpLOC.php, line 38 - Contains \SiteAudit\Check\Codebase\PhpLOC.
Class
- SiteAuditCheckCodebasePhpLOC
- Class SiteAuditCheckCodebasePhpLOC.
Code
public function getResultInfo() {
if (isset($this->registry['phploc_path_error'])) {
return dt('Missing phploc.');
}
if (isset($this->registry['custom_code'])) {
return dt('Cannot measure the size of the project; no custom code path specified.');
}
$human_readable = array(
'loc' => 'Lines of Code (LOC)',
'files' => 'Files',
'directories' => 'Directories',
'functions' => 'Functions',
'namespaces' => 'Namespaces',
'methods' => 'Methods',
);
$ret_val = '';
if (drush_get_option('html') == TRUE) {
$ret_val .= '<table class="table table-condensed">';
$ret_val .= '<thead><tr><th>' . dt('Metric') . '</th><th>' . dt('Value') . '</th></tr></thead>';
foreach ($this->registry['phploc_out'] as $filename => $metrics) {
$ret_val .= "<tr align='center'><td colspan='3'><b>File/Directory</b>: {$filename}</td></tr>";
foreach ($human_readable as $metric => $name) {
$e = $metrics
->xpath('//' . $metric);
$ret_val .= "<tr><td>{$name}</td><td>" . (string) $e[0] . "</td></tr>";
}
}
$ret_val .= '</table>';
}
else {
$rows = 0;
foreach ($this->registry['phploc_out'] as $filename => $metrics) {
if ($rows++ > 0) {
$ret_val .= PHP_EOL;
if (!drush_get_option('json')) {
$ret_val .= str_repeat(' ', 4);
}
}
$ret_val .= dt('File/Directory: @filename', array(
'@filename' => $filename,
));
foreach ($human_readable as $metric => $name) {
$ret_val .= PHP_EOL;
if (!drush_get_option('json')) {
$ret_val .= str_repeat(' ', 6);
}
$e = $metrics
->xpath('//' . $metric);
$ret_val .= $name . ': ' . (string) $e[0];
}
}
}
return $ret_val;
}