chamilo/chamilo-lms

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

Summary

Maintainability
A
0 mins
Test Coverage

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

        $paramsToString = '?'.http_build_query($params);

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 using undefined variables such as '$params' which will lead to PHP notices.
Open

        $params['rand'] = uniqid('u_', true);

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 using undefined variables such as '$params' which will lead to PHP notices.
Open

        $params['w'] = 64;

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

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

            } else {
                $qb->andWhere('gu.relationType = :relationType')
                    ->setParameter('relationType', $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 searchGroupsByTags uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $qb->select('g.id, g.title, g.description, g.url, g.picture');
        }

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 '$withImage'.
Open

    public function getGroupsByUser(int $userId, int $relationType = 0, bool $withImage = false): array

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

The parameter $number_of_items is not named in camelCase.
Open

    public function searchGroupsByTags(string $tag, int $from = 0, int $number_of_items = 10, bool $getCount = false)
    {
        $qb = $this->createQueryBuilder('g');

        if ($getCount) {

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 getUsersByGroup(int $groupID)

Missing function doc comment
Open

    public function isGroupModerator(int $groupId, int $userId): bool

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

    public function searchGroupsByTags(string $tag, int $from = 0, int $number_of_items = 10, bool $getCount = false)

Missing function doc comment
Open

    public function addUserToGroup(int $userId, int $groupId, int $relationType = Usergroup::GROUP_USER_PERMISSION_READER): void

Missing function doc comment
Open

    public function searchGroupsByTags(string $tag, int $from = 0, int $number_of_items = 10, bool $getCount = false)

Missing function doc comment
Open

    public function getNewestGroups(int $limit = 30, string $query = ''): array

Add a single space around assignment operators
Open

declare(strict_types=1);

Missing function doc comment
Open

    public function isGroupMember(int $groupId, User $user): bool

Missing function doc comment
Open

    public function findGroupById($id)

Missing function doc comment
Open

    public function searchGroups(string $searchTerm): array

Missing function doc comment
Open

    public function removeUserFromGroup(int $userId, int $groupId, bool $checkLeaveRestriction = true): bool

Doc comment for parameter $relationType does not match actual variable name $userId
Open

     * @param int|array $relationType

Missing function doc comment
Open

    public function getPopularGroups(int $limit = 30): array

Missing function doc comment
Open

    public function getInvitedUsers(int $groupId): array

Missing function doc comment
Open

    public function updateUserRole($userId, $groupId, $relationType = Usergroup::GROUP_USER_PERMISSION_READER): void

Missing function doc comment
Open

    public function countMembers(int $usergroupId): int

Missing function doc comment
Open

    public function __construct(

Missing class doc comment
Open

class UsergroupRepository extends ResourceRepository

Missing function doc comment
Open

    public function getUsergroupPicture($userGroupId): string

Missing function doc comment
Open

    public function getUserGroupRole(int $groupId, int $userId): ?int

Missing function doc comment
Open

    public function getInvitedUsersByGroup(int $groupID)

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

                ->setMaxResults($number_of_items)

The 'getUseMultipleUrl()' method which returns a boolean should be named 'is...()' or 'has...()'
Open

    public function getUseMultipleUrl(): bool
    {
        // TODO: Implement the actual logic to determine if multi-URLs should be used.
        // For now, returning false as a default value.
        return false;

BooleanGetMethodName

Since: 0.2

Looks for methods named 'getX()' with 'boolean' as the return type. The convention is to name these methods 'isX()' or 'hasX()'.

Example

class Foo {
    /**
     * @return boolean
     */
    public function getFoo() {} // bad
    /**
     * @return bool
     */
    public function isFoo(); // ok
    /**
     * @return boolean
     */
    public function getFoo($bar); // ok, unless checkParameterizedMethods=true
}

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

Line indented incorrectly; expected 4 spaces, found 8
Open

        private readonly AccessUrlHelper $accessUrlHelper,

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 searchGroupsByTags(string $tag, int $from = 0, int $number_of_items = 10, bool $getCount = false)
    {
        $qb = $this->createQueryBuilder('g');

        if ($getCount) {

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