chamilo/chamilo-lms

View on GitHub
src/CoreBundle/Repository/Node/UserRepository.php

Summary

Maintainability
A
0 mins
Test Coverage

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

class UserRepository extends ResourceRepository implements PasswordUpgraderInterface
{
    protected ?UserPasswordHasherInterface $hasher = null;

    public const USER_IMAGE_SIZE_SMALL = 1;

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

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

            } else {
                $childNode->setParent(null);
            }

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 method deleteUser uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                $user->setActive(User::SOFT_DELETED);
                $em->persist($user);
            }

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 method findUsersToSendMessage uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                $this->addOnlyMyFriendsQueryBuilder($currentUserId, $qb);
                /*$dql = 'SELECT DISTINCT U
                        FROM ChamiloCoreBundle:AccessUrlRelUser R, ChamiloCoreBundle:UserRelUser UF
                        INNER JOIN ChamiloCoreBundle:User AS U

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 method findUsersToSendMessage uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            if ('true' === $allowSendMessageToAllUsers) {
                $this->addNotCurrentUserQueryBuilder($currentUserId, $qb);
            } else {
                return [];

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 method searchUsersByTags uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $qb->select('DISTINCT u.id, u.username, u.firstname, u.lastname, u.email, u.pictureUri, u.status');
        }

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 method findUsersToSendMessage uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                return [];
            }

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 method getExtraUserData uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                $extraData[$key] = $value;
            }

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 method relateUsers uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $existingRelation->setRelationType($relationType);
        }

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 method relateUsers uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $existingRelationInverse->setRelationType($relationType);
        }

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

Avoid unused parameters such as '$limit'.
Open

    public function findUsersToSendMessage(int $currentUserId, ?string $searchFilter = null, int $limit = 10)

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 unused local variables such as '$dql'.
Open

        $dql = null;

UnusedLocalVariable

Since: 0.2

Detects when a local variable is declared and/or assigned, but not used.

Example

class Foo {
    public function doSomething()
    {
        $i = 5; // Unused
    }
}

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

The parameter $number_of_items is not named in camelCase.
Open

    public function searchUsersByTags(
        string $tag,
        ?int $excludeUserId = null,
        int $fieldId = 0,
        int $from = 0,

CamelCaseParameterName

Since: 0.2

It is considered best practice to use the camelCase notation to name parameters.

Example

class ClassName {
    public function doSomething($user_name) {
    }
}

Source

Missing function doc comment
Open

    public function loadUserByIdentifier(string $identifier): ?User

Missing function doc comment
Open

    public function setHasher(UserPasswordHasherInterface $hasher): void

Missing function doc comment
Open

    public function canonicalize(string $string): string

Missing function doc comment
Open

    public function updatePassword(User $user): void

Add a single space around assignment operators
Open

declare(strict_types=1);

Missing function doc comment
Open

    public function __construct(

Missing function doc comment
Open

    public function updateCanonicalFields(User $user): void

Missing function doc comment
Open

    public function updateUser(User $user, bool $andFlush = true): void

Missing function doc comment
Open

    public function createUser(): User

Missing class doc comment
Open

class UserRepository extends ResourceRepository implements PasswordUpgraderInterface

Missing function doc comment
Open

    public function getExtraUserDataByField(int $userId, string $fieldVariable, bool $allVisibility = true): array

Missing function doc comment
Open

    public function getUserRelationWithType(int $userId, int $friendId): ?array

Missing function doc comment
Open

    public function isPasswordValid(User $user, string $plainPassword): bool

Missing function doc comment
Open

    public function addActiveAndNotAnonUserQueryBuilder(?QueryBuilder $qb = null): QueryBuilder

Missing function doc comment
Open

    public function getFriendsNotInGroup(int $userId, int $groupId)

Missing function doc comment
Open

    public function addAccessUrlQueryBuilder(int $accessUrlId, ?QueryBuilder $qb = null): QueryBuilder

Missing function doc comment
Open

    public function deleteUser(User $user, bool $destroy = false): void

Declare public methods first,then protected ones and finally private ones
Open

    public function getFallbackUser(): ?User

Declare public methods first,then protected ones and finally private ones
Open

    public function getFriendsNotInGroup(int $userId, int $groupId)

Missing function doc comment
Open

    public function searchUsersByTags(

Missing function doc comment
Open

    public function getRootUser(): User

Missing function doc comment
Open

    public function addRoleListQueryBuilder(array $roles, ?QueryBuilder $qb = null): QueryBuilder

Missing function doc comment
Open

    public function getFallbackUser(): ?User

Doc comment for parameter $accessUrlId does not match actual variable name $keyword
Open

     * @param int    $accessUrlId The access URL ID

Missing function doc comment
Open

    public function findByUsername(string $username): ?User

Doc comment for parameter $keyword does not match actual variable name $role
Open

     * @param string $keyword     The query to filter

Missing function doc comment
Open

    public function addExpirationDateQueryBuilder(?QueryBuilder $qb = null): QueryBuilder

Variable "number_of_items" is not in valid camel caps format
Open

                ->setMaxResults($number_of_items)

Missing function doc comment
Open

    public function getExtraUserData(int $userId, bool $prefix = false, bool $allVisibility = true, bool $splitMultiple = false, ?int $fieldFilter = null): array

Variable "number_of_items" is not in valid camel caps format
Open

        int $number_of_items = 10,

Missing function doc comment
Open

    public function getUserPicture(

Missing function doc comment
Open

    public function upgradePassword(PasswordAuthenticatedUserInterface $user, string $newHashedPassword): void

Missing function doc comment
Open

    public function addUserToResourceNode(int $userId, int $creatorId): ResourceNode

Missing function doc comment
Open

    public function relateUsers(User $user1, User $user2, int $relationType): void

Missing function doc comment
Open

    public function findByRoleList(array $roleList, string $keyword, int $accessUrlId = 0)

Arguments with default values must be at the end of the argument list
Open

        $addRandomId = true,

Line indented incorrectly; expected 4 spaces, found 8
Open

        private readonly IllustrationRepository $illustrationRepository

The variable $number_of_items is not named in camelCase.
Open

    public function searchUsersByTags(
        string $tag,
        ?int $excludeUserId = null,
        int $fieldId = 0,
        int $from = 0,

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

There are no issues that match your filters.

Category
Status