chamilo/chamilo-lms

View on GitHub
src/CoreBundle/Controller/Admin/IndexBlocksController.php

Summary

Maintainability
A
0 mins
Test Coverage

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

        } else {
            $items[] = [
                'class' => 'item-user-import',
                'url' => $this->generateUrl('legacy_main', ['name' => 'admin/user_import.php']),
                'label' => $this->translator->trans('Import users list'),

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

        $languageInterface = api_get_language_isocode();

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

Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead.
Open

#[Security("is_granted('ROLE_ADMIN') or is_granted('ROLE_SESSION_MANAGER')")]

Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead.
Open

#[Route('/admin/index', name: 'admin_index_blocks')]

Missing function doc comment
Open

    public function __construct(

Missing function doc comment
Open

    public function __invoke(): JsonResponse

You must use "/**" style comments for a class comment
Open

class IndexBlocksController extends BaseController

Add a single space around assignment operators
Open

declare(strict_types=1);

Line indented incorrectly; expected 4 spaces, found 8
Open

        private readonly PageRepository $pageRepository,

Line indented incorrectly; expected 4 spaces, found 8
Open

        private readonly PageCategoryRepository $pageCategoryRepository,

Line indented incorrectly; expected 4 spaces, found 8
Open

        private readonly TranslatorInterface $translator,

Line indented incorrectly; expected 4 spaces, found 8
Open

        private readonly SerializerInterface $serializer

Line indented incorrectly; expected 4 spaces, found 8
Open

        private readonly SettingsManager $settingsManager,

There are no issues that match your filters.

Category
Status