skqr/hateoas

View on GitHub
JsonApi/Request/ParamEntityFinder.php

Summary

Maintainability
A
1 hr
Test Coverage

Function selectRelationshipEntities has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    private function selectRelationshipEntities(
        Params $params, array $entities
    )
    {
        $selected = [];
Severity: Minor
Found in JsonApi/Request/ParamEntityFinder.php - About 45 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

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

    private function canAccessEntities(Params $params, Collection $entities)
    {
        $access = NULL;

        if (RequestAction::TARGET_RELATIONSHIP === $params->action->target) {
Severity: Minor
Found in JsonApi/Request/ParamEntityFinder.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

The class ParamEntityFinder has a coupling between objects value of 17. Consider to reduce the number of dependencies under 13.
Open

class ParamEntityFinder
{
    const ACCESS_VIEW = 'view',
        ACCESS_EDIT = 'edit',
        ACCESS_DELETE = 'delete';
Severity: Minor
Found in JsonApi/Request/ParamEntityFinder.php by phpmd

CouplingBetweenObjects

Since: 1.1.0

A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

Example

class Foo {
    /**
     * @var \foo\bar\X
     */
    private $x = null;

    /**
     * @var \foo\bar\Y
     */
    private $y = null;

    /**
     * @var \foo\bar\Z
     */
    private $z = null;

    public function setFoo(\Foo $foo) {}
    public function setBar(\Bar $bar) {}
    public function setBaz(\Baz $baz) {}

    /**
     * @return \SplObjectStorage
     * @throws \OutOfRangeException
     * @throws \InvalidArgumentException
     * @throws \ErrorException
     */
    public function process(\Iterator $it) {}

    // ...
}

Source https://phpmd.org/rules/design.html#couplingbetweenobjects

Avoid using static access to class '\GoIntegro\Hateoas\Util\Inflector' in method 'findRelationshipEntities'.
Open

        $method = 'get' . Util\Inflector::camelize($params->relationship);
Severity: Minor
Found in JsonApi/Request/ParamEntityFinder.php by phpmd

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 unused parameters such as '$params'.
Open

        Params $params, array $entities
Severity: Minor
Found in JsonApi/Request/ParamEntityFinder.php by phpmd

UnusedFormalParameter

Since: 0.2

Avoid passing parameters to methods or constructors and then not using those parameters.

Example

class Foo
{
    private function bar($howdy)
    {
        // $howdy is not used
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

Avoid variables with short names like $em. Configured minimum length is 3.
Open

    private $em;
Severity: Minor
Found in JsonApi/Request/ParamEntityFinder.php by phpmd

ShortVariable

Since: 0.2

Detects when a field, local, or parameter has a very short name.

Example

class Something {
    private $q = 15; // VIOLATION - Field
    public static function main( array $as ) { // VIOLATION - Formal
        $r = 20 + $this->q; // VIOLATION - Local
        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
            $r += $this->q;
        }
    }
}

Source https://phpmd.org/rules/naming.html#shortvariable

Avoid variables with short names like $em. Configured minimum length is 3.
Open

        EntityManagerInterface $em,
Severity: Minor
Found in JsonApi/Request/ParamEntityFinder.php by phpmd

ShortVariable

Since: 0.2

Detects when a field, local, or parameter has a very short name.

Example

class Something {
    private $q = 15; // VIOLATION - Field
    public static function main( array $as ) { // VIOLATION - Formal
        $r = 20 + $this->q; // VIOLATION - Local
        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
            $r += $this->q;
        }
    }
}

Source https://phpmd.org/rules/naming.html#shortvariable

The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line
Open

    {

The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line
Open

    {

TRUE, FALSE and NULL must be lowercase; expected "false" but found "FALSE"
Open

                return FALSE;

TRUE, FALSE and NULL must be lowercase; expected "true" but found "TRUE"
Open

        return TRUE;

There must be one USE keyword per declaration
Open

use Symfony\Component\Security\Core\SecurityContextInterface,

Multi-line function declarations must define one parameter per line
Open

        Params $params, array $entities

There must be one USE keyword per declaration
Open

use Doctrine\Common\Collections\Collection,

Multi-line function declarations must define one parameter per line
Open

        Params $params, array $entities

TRUE, FALSE and NULL must be lowercase; expected "null" but found "NULL"
Open

        $access = NULL;

The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line
Open

    {

The closing parenthesis and the opening brace of a multi-line function declaration must be on the same line
Open

    {

Only one argument is allowed per line in a multi-line function call
Open

                (string) $entity->getId(), $params->relationshipIds

Only one argument is allowed per line in a multi-line function call
Open

                    self::ACCESS_VIEW, $entity

Only one argument is allowed per line in a multi-line function call
Open

                self::ACCESS_VIEW, $entity

Line exceeds 120 characters; contains 127 characters
Open

        ERROR_ACCESS_CONTROL_FILTER = "Access control voters are not being supported properly by corresponding query filters.";

Expected 0 spaces after opening bracket; newline found
Open

        if (

Expected 0 spaces after opening bracket; newline found
Open

        if (

There are no issues that match your filters.

Category
Status