class/Common/ServerStats.php
Method getServerStats
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
public static function getServerStats()
{
$moduleDirName = basename(dirname(dirname(__DIR__)));
$moduleDirNameUpper = strtoupper($moduleDirName);
xoops_loadLanguage('common', $moduleDirName);
Avoid assigning values to variables in if clauses and the like (line '46', column '27'). Open
Open
public static function getServerStats()
{
$moduleDirName = basename(dirname(dirname(__DIR__)));
$moduleDirNameUpper = strtoupper($moduleDirName);
xoops_loadLanguage('common', $moduleDirName);
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Line exceeds 120 characters; contains 236 characters Open
Open
$downloads = ini_get('file_uploads') ? '<span style="color: #008000;">' . constant('CO_' . $moduleDirNameUpper . '_ON') . '</span>' : '<span style="color: #ff0000;">' . constant('CO_' . $moduleDirNameUpper . '_OFF') . '</span>';
- Exclude checks
Line exceeds 120 characters; contains 168 characters Open
Open
$html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_MAXUPLOADSIZE') . ' <b><span style="color: blue;">' . ini_get('upload_max_filesize') . '</span></b>';
- Exclude checks
Line exceeds 120 characters; contains 160 characters Open
Open
$html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_MAXPOSTSIZE') . ' <b><span style="color: blue;">' . ini_get('post_max_size') . '</span></b>';
- Exclude checks
Line exceeds 120 characters; contains 137 characters Open
Open
$html .= "<legend style='font-weight: bold; color: #900;'>" . constant('CO_' . $moduleDirNameUpper . '_IMAGEINFO') . '</legend>';
- Exclude checks
Line exceeds 120 characters; contains 130 characters Open
Open
$html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_GDLIBVERSION') . '<b>' . $gdlib['GD Version'] . '</b>';
- Exclude checks
Line exceeds 120 characters; contains 239 characters Open
Open
$gdlib = function_exists('gd_info') ? '<span style="color: #008000;">' . constant('CO_' . $moduleDirNameUpper . '_GDON') . '</span>' : '<span style="color: #ff0000;">' . constant('CO_' . $moduleDirNameUpper . '_GDOFF') . '</span>';
- Exclude checks
Line exceeds 120 characters; contains 159 characters Open
Open
$html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_MEMORYLIMIT') . ' <b><span style="color: blue;">' . ini_get('memory_limit') . '</span></b>';
- Exclude checks