skqr/hateoas

View on GitHub
JsonApi/Serializer/TopLevelLinkedLinksSerializer.php

Summary

Maintainability
A
0 mins
Test Coverage

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

        } else {
            $urlTemplate = $this->buildByRelationshipUrlTemplate(
                $resource, $relationship
            );
        }

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

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

    {

There must be one USE keyword per declaration
Open

use GoIntegro\Hateoas\JsonApi\ResourceEntityInterface,

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

    {

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

        EntityResource $resource, ResourceRelationship $relationship

Expected 1 space after FUNCTION keyword; 0 found
Open

            $walk = function($relationship) use (&$json, $resource) {

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

        EntityResource $resource, ResourceRelationship $relationship

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

        $urlTemplate = NULL;

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

    {

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

        EntityResource $resource, ResourceRelationship $relationship

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

        EntityResource $resource, $relationshipName

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

        EntityResource $resource, ResourceRelationship $relationship

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

                $resource, $relationship

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

                $resource, $relationship

Line exceeds 120 characters; contains 179 characters
Open

    const ERROR_MISSING_MAPPING_FIELD = "Una de las relaciones declaradas o evaluadas como \"link-only\" posiblemente no tenga un campo de mapeo inverso en la entidad vinculada.",

Inline control structures are not allowed
Open

            if (!$resource->getMetadata()->hasRelationships()) continue;

Expected 0 spaces after opening bracket; newline found
Open

        if (

There are no issues that match your filters.

Category
Status