Function confReportAll
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
public function confReportAll(): void
{
\App\Process::$requestMode = 'Cron';
\App\Utils\ConfReport::$sapi = 'cron';
$all = \App\Utils\ConfReport::getAll();
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method confReportAll
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function confReportAll(): void
{
\App\Process::$requestMode = 'Cron';
\App\Utils\ConfReport::$sapi = 'cron';
$all = \App\Utils\ConfReport::getAll();
Function confReportErrors
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function confReportErrors(): void
{
\App\Process::$requestMode = 'Cron';
\App\Utils\ConfReport::$sapi = 'cron';
foreach (\App\Utils\ConfReport::$types as $type) {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
The method confReportAll() has an NPath complexity of 259. The configured NPath complexity threshold is 200. Open
public function confReportAll(): void
{
\App\Process::$requestMode = 'Cron';
\App\Utils\ConfReport::$sapi = 'cron';
$all = \App\Utils\ConfReport::getAll();
- Read upRead up
- Exclude checks
NPathComplexity
Since: 0.1
The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.
Example
class Foo {
function bar() {
// lots of complicated code
}
}
Source https://phpmd.org/rules/codesize.html#npathcomplexity
The method confReportAll() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10. Open
public function confReportAll(): void
{
\App\Process::$requestMode = 'Cron';
\App\Utils\ConfReport::$sapi = 'cron';
$all = \App\Utils\ConfReport::getAll();
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
Avoid using static access to class '\App\Json' in method 'confReportAll'. Open
$value = \is_array($value) ? \App\Json::encode($value) : $value;
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Utils\ConfReport' in method 'confReportAll'. Open
$all = \App\Utils\ConfReport::getAll();
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Utils\ConfReport' in method 'confReportErrors'. Open
foreach (\App\Utils\ConfReport::getErrors($type, true) as $name => $item) {
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Language' in method 'confReportAll'. Open
$value = \App\Language::translate($value);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
syntax error, unexpected '=>' (T_DOUBLE_ARROW), expecting ',' or ')'
Open
$item['val'] = preg_replace_callback("'<b class=\"text-danger\">(.*?)</b>'si", fn ($match) => "<light_red>{$match['1']}</light_red>", $item['val']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Process::$requestMode = 'Cron';
- Exclude checks
Line exceeds 120 characters; contains 160 characters Open
$item['val'] = preg_replace_callback("'<b class=\"text-danger\">(.*?)</b>'si", fn ($match) => "<light_red>{$match['1']}</light_red>", $item['val']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $moduleName = 'Environment';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Process::$requestMode = 'Cron';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach (\App\Utils\ConfReport::$types as $type) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->climate->border('─', 140);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->climate->underline()->bold()->out(" $type");
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$all = \App\Utils\ConfReport::getAll();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$item['testCli']) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$value = \App\Language::translate($value);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$table[] = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$item['recommended'] = preg_replace_callback("'<b class=\"text-danger\">(.*?)</b>'si", fn ($match) => "<light_red>{$match['1']}</light_red>", $item['recommended']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->htmlToText($item);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (false !== strpos($item['val'], '<b class="text-danger">')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($all as $type => $items) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array &$item
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function htmlToText(array &$item): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$item['val'] = preg_replace_callback("'<b class=\"text-danger\">(.*?)</b>'si", fn ($match) => "<light_red>{$match['1']}</light_red>", $item['val']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->climate->table($table);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!empty($item['isHtml'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Server configuration - All.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'confReportErrors' => 'Server configuration - Errors',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Utils\ConfReport::$sapi = 'cron';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($table) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($items as $name => $item) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$value = $item['cron'] ?? $item['www'] ?? '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string[] Methods list */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach (\App\Utils\ConfReport::getErrors($type, true) as $name => $item) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (0 === strpos($value, 'LBL_')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->climate->border('─', 140);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Convert html to cli text.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $methods = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function confReportAll(): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
continue;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$value = \is_array($value) ? \App\Json::encode($value) : $value;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Line exceeds 120 characters; contains 176 characters Open
$item['recommended'] = preg_replace_callback("'<b class=\"text-danger\">(.*?)</b>'si", fn ($match) => "<light_red>{$match['1']}</light_red>", $item['recommended']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'confReportAll' => 'Server configuration - All',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Recommended' => empty($item['recommended']) ? '-' : print_r($item['recommended'], true),
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($table) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->climate->underline()->bold()->out(" $type");
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function confReportErrors(): void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$table = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Value' => $item['cron'] ?? '-',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$table = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->climate->border('─', 140);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Server configuration - Errors.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$table[] = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Recommended' => $item['recommended'] ?? '-',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->climate->border('─', 140);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (false !== strpos($item['recommended'], '<b class="text-danger">')) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Parameter' => $name,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->climate->table($table);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Utils\ConfReport::$sapi = 'cron';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/**
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!empty($item['isHtml'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->htmlToText($item);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Parameter' => $item['status'] ? $name : "<light_red>{$name}</light_red>",
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Value' => $item['status'] ? $value : ("<light_red>{$value}</light_red>"),
- Exclude checks
Space before opening parenthesis of function call prohibited Open
$item['val'] = preg_replace_callback("'<b class=\"text-danger\">(.*?)</b>'si", fn ($match) => "<light_red>{$match['1']}</light_red>", $item['val']);
- Exclude checks
Space before opening parenthesis of function call prohibited Open
$item['recommended'] = preg_replace_callback("'<b class=\"text-danger\">(.*?)</b>'si", fn ($match) => "<light_red>{$match['1']}</light_red>", $item['recommended']);
- Exclude checks