chamilo/chamilo-lms

View on GitHub
src/CoreBundle/Repository/SysAnnouncementRepository.php

Summary

Maintainability
A
0 mins
Test Coverage

The method getAnnouncements() has an NPath complexity of 472. The configured NPath complexity threshold is 200.
Open

    public function getAnnouncements(User $user, AccessUrl $url, string $iso): array
    {
        $qb = $this->getAnnouncementsQueryBuilder($iso, $url, $user);

        $announcements = $qb->getQuery()->getResult();

NPathComplexity

Since: 0.1

The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

Example

class Foo {
    function bar() {
        // lots of complicated code
    }
}

Source https://phpmd.org/rules/codesize.html#npathcomplexity

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

        $orX->addMultiple($conditions);

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 '$conditions' which will lead to PHP notices.
Open

                $conditions[] = $qb->expr()->like('s.roles', $qb->expr()->literal('%'.$role.'%'));

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 '$conditions' which will lead to PHP notices.
Open

        $conditions[] = $qb->expr()->like('s.roles', $qb->expr()->literal('%ROLE_ANONYMOUS%'));

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

                    } else {
                        $promotionList = $announcement->getCareer()->getPromotions();
                    }

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

Missing function doc comment
Open

    public function __construct(ManagerRegistry $registry, ParameterBagInterface $parameterBag, Security $security)

Missing function doc comment
Open

    public function getAnnouncementsQueryBuilder(string $iso, AccessUrl $url, ?User $user = null): QueryBuilder

Missing function doc comment
Open

    public function getVisibilityList(): array

Missing function doc comment
Open

    public function update(SysAnnouncement $sysAnnouncement, bool $andFlush = true): void

Missing function doc comment
Open

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

Missing function doc comment
Open

    public function delete(int $id): void

Add a single space around assignment operators
Open

declare(strict_types=1);

Missing function doc comment
Open

    public function getAnnouncements(User $user, AccessUrl $url, string $iso): array

Missing function doc comment
Open

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

Missing class doc comment
Open

class SysAnnouncementRepository extends ServiceEntityRepository

There are no issues that match your filters.

Category
Status