andreypostal/cli

View on GitHub
examples/ParamsValidation/Service.php

Summary

Maintainability
A
0 mins
Test Coverage

The method process uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Wontfix

        } else {
            self::console("Oh, here he is >> {$thisMayNot} <<", ConsoleLevel::INFO);
        }
Severity: Minor
Found in examples/ParamsValidation/Service.php by phpmd

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

        $thisExists = $context->get('required');
Severity: Critical
Found in examples/ParamsValidation/Service.php by phan

Static call to undeclared method \Andrey\Cli\Examples\ParamsValidation\Service::console
Open

        self::console("Check it out: >> {$thisExists} <<", ConsoleLevel::SUCCESS);
Severity: Critical
Found in examples/ParamsValidation/Service.php by phan

Reference to constant WARNING from undeclared class \Andrey\Cli\Types\ConsoleLevel
Open

            self::console("OH NO >.<", ConsoleLevel::WARNING);
Severity: Critical
Found in examples/ParamsValidation/Service.php by phan

Class uses undeclared trait \Andrey\Cli\Utils\Output
Open

class Service
Severity: Critical
Found in examples/ParamsValidation/Service.php by phan

Parameter $context has undeclared type \Andrey\Cli\Types\Context
Open

    public function process(Context $context): void
Severity: Minor
Found in examples/ParamsValidation/Service.php by phan

Reference to constant SUCCESS from undeclared class \Andrey\Cli\Types\ConsoleLevel
Open

        self::console("Check it out: >> {$thisExists} <<", ConsoleLevel::SUCCESS);
Severity: Critical
Found in examples/ParamsValidation/Service.php by phan

Static call to undeclared method \Andrey\Cli\Examples\ParamsValidation\Service::console
Open

            self::console("OH NO >.<", ConsoleLevel::WARNING);
Severity: Critical
Found in examples/ParamsValidation/Service.php by phan

Call to method get from undeclared class \Andrey\Cli\Types\Context
Open

        $thisMayNot = $context->get('optional');
Severity: Critical
Found in examples/ParamsValidation/Service.php by phan

Reference to constant INFO from undeclared class \Andrey\Cli\Types\ConsoleLevel
Open

            self::console("Oh, here he is >> {$thisMayNot} <<", ConsoleLevel::INFO);
Severity: Critical
Found in examples/ParamsValidation/Service.php by phan

Static call to undeclared method \Andrey\Cli\Examples\ParamsValidation\Service::console
Open

            self::console("Oh, here he is >> {$thisMayNot} <<", ConsoleLevel::INFO);
Severity: Critical
Found in examples/ParamsValidation/Service.php by phan

There are no issues that match your filters.

Category
Status