examples/ParamsValidation/Service.php
The method process uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Wontfix
Wontfix
} else {
self::console("Oh, here he is >> {$thisMayNot} <<", ConsoleLevel::INFO);
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Call to method get
from undeclared class \Andrey\Cli\Types\Context
Open
Open
$thisExists = $context->get('required');
- Exclude checks
Static call to undeclared method \Andrey\Cli\Examples\ParamsValidation\Service::console
Open
Open
self::console("Check it out: >> {$thisExists} <<", ConsoleLevel::SUCCESS);
- Exclude checks
Reference to constant WARNING
from undeclared class \Andrey\Cli\Types\ConsoleLevel
Open
Open
self::console("OH NO >.<", ConsoleLevel::WARNING);
- Exclude checks
Class uses undeclared trait \Andrey\Cli\Utils\Output
Open
Open
class Service
- Exclude checks
Parameter $context
has undeclared type \Andrey\Cli\Types\Context
Open
Open
public function process(Context $context): void
- Exclude checks
Reference to constant SUCCESS
from undeclared class \Andrey\Cli\Types\ConsoleLevel
Open
Open
self::console("Check it out: >> {$thisExists} <<", ConsoleLevel::SUCCESS);
- Exclude checks
Static call to undeclared method \Andrey\Cli\Examples\ParamsValidation\Service::console
Open
Open
self::console("OH NO >.<", ConsoleLevel::WARNING);
- Exclude checks
Call to method get
from undeclared class \Andrey\Cli\Types\Context
Open
Open
$thisMayNot = $context->get('optional');
- Exclude checks
Reference to constant INFO
from undeclared class \Andrey\Cli\Types\ConsoleLevel
Open
Open
self::console("Oh, here he is >> {$thisMayNot} <<", ConsoleLevel::INFO);
- Exclude checks
Static call to undeclared method \Andrey\Cli\Examples\ParamsValidation\Service::console
Open
Open
self::console("Oh, here he is >> {$thisMayNot} <<", ConsoleLevel::INFO);
- Exclude checks