chamilo/chamilo-lms

View on GitHub
src/CoreBundle/Service/ScheduledAnnouncementService.php

Summary

Maintainability
A
0 mins
Test Coverage

The method sendPendingMessages() has an NPath complexity of 933192. The configured NPath complexity threshold is 200.
Open

    public function sendPendingMessages(int $urlId, bool $debug = false): int
    {
        if (!$this->allowed()) {
            if ($debug) {
                error_log('Announcements not allowed.');

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

                                $tags['(('.strtolower($extraField['variable']).'))'] = $valueExtra['value'] ?? '';

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

                            $message = str_replace(array_keys($tags), $tags, $message);

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

                            $message = str_replace(array_keys($tags), $tags, $message);

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 class ScheduledAnnouncementService has a coupling between objects value of 15. Consider to reduce the number of dependencies under 13.
Open

class ScheduledAnnouncementService
{
    public function __construct(
        private readonly ScheduledAnnouncementRepository $announcementRepository,
        private readonly AccessUrlRepository $accessUrlRepository,

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

    private function buildCoachMessage($announcement, $generalCoaches, $message): string

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

    private function buildMessage($announcement, Session $session, User $user, $courseInfo, $attachments, $progress): string

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

Add a single space around assignment operators
Open

declare(strict_types=1);

Missing class doc comment
Open

class ScheduledAnnouncementService

Closing brace must be on a line by itself
Open

    ) {}

Missing function doc comment
Open

    public function __construct(

Line indented incorrectly; expected 4 spaces, found 8
Open

        private readonly EntityManager $em,

Line indented incorrectly; expected 4 spaces, found 8
Open

        private readonly AccessUrlRepository $accessUrlRepository,

Line indented incorrectly; expected 4 spaces, found 8
Open

        private readonly TranslatorInterface $translator

Line indented incorrectly; expected 4 spaces, found 8
Open

        private readonly SettingsManager $settingsManager,

Line indented incorrectly; expected 4 spaces, found 8
Open

        private readonly SessionRepository $sessionRepository,

Line indented incorrectly; expected 4 spaces, found 8
Open

        private readonly MessageHelper $messageHelper,

Line indented incorrectly; expected 4 spaces, found 8
Open

        private readonly ScheduledAnnouncementRepository $announcementRepository,

Closing brace must be on a line by itself
Open

    ) {}

There are no issues that match your filters.

Category
Status