rinvex/laravel-support

View on GitHub
src/Traits/Macroable.php

Summary

Maintainability
A
55 mins
Test Coverage

Avoid too many return statements within this method.
Open

                return $this->macroableCall($method, $parameters);
Severity: Major
Found in src/Traits/Macroable.php - About 30 mins to fix

Function __call has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function __call($method, $parameters)
    {
        if (in_array($method, ['increment', 'decrement'])) {
            return $this->{$method}(...$parameters);
        }
Severity: Minor
Found in src/Traits/Macroable.php - About 25 mins to fix

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

Avoid using undefined variables such as '::$relationResolvers' which will lead to PHP notices.
Open

            if ($resolver = (static::$relationResolvers[get_class($this)][$method] ?? null)) {
Severity: Minor
Found in src/Traits/Macroable.php by phpmd

UndefinedVariable

Since: 2.8.0

Detects when a variable is used that has not been defined before.

Example

class Foo
{
    private function bar()
    {
        // $message is undefined
        echo $message;
    }
}

Source https://phpmd.org/rules/cleancode.html#undefinedvariable

Avoid assigning values to variables in if clauses and the like (line '39', column '17').
Open

    public function __call($method, $parameters)
    {
        if (in_array($method, ['increment', 'decrement'])) {
            return $this->{$method}(...$parameters);
        }
Severity: Minor
Found in src/Traits/Macroable.php by phpmd

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

There are no issues that match your filters.

Category
Status