chamilo/chamilo-lms

View on GitHub
src/CoreBundle/Migrations/AbstractMigrationChamilo.php

Summary

Maintainability
A
0 mins
Test Coverage

The method fixItemProperty() has an NPath complexity of 4616. The configured NPath complexity threshold is 200.
Open

    public function fixItemProperty(
        $tool,
        ResourceRepository $repo,
        $course,
        $admin,

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

The method addSettingCurrent has 13 parameters. Consider reducing the number of parameters to less than 10.
Open

    public function addSettingCurrent(
        $variable,
        $subKey,
        $type,
        $category,

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

abstract class AbstractMigrationChamilo extends AbstractMigration
{
    public const BATCH_SIZE = 20;

    protected ?EntityManagerInterface $entityManager = null;

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 assigning values to variables in if clauses and the like (line '302', column '27').
Open

    public function fixItemProperty(
        $tool,
        ResourceRepository $repo,
        $course,
        $admin,

IfStatementAssignment

Since: 2.7.0

Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

Example

class Foo
{
    public function bar($flag)
    {
        if ($foo = 'bar') { // possible typo
            // ...
        }
        if ($baz = 0) { // always false
            // ...
        }
    }
}

Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

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

        } else {
            $selectedValue = (string) $settingValue;
        }

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

                } else {
                    $group = $groupList[$groupId] = $groupRepo->find($groupId);
                }

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

                    } else {
                        $option['text'] = 'No';
                    }

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

            } else {
                $lastUpdatedAt = new DateTime($item['lastedit_date'], new DateTimeZone('UTC'));
            }

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

                } else {
                    $session = $sessionList[$sessionId] = $sessionRepo->find($sessionId);
                }

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

    public function removeSettingCurrent($variable): void

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

        $rootPath = $this->container->get('kernel')->getProjectDir();

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

Avoid unused parameters such as '$description'.
Open

        $description = ''

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

Missing function doc comment
Open

    public function setEntityManager(EntityManagerInterface $entityManager): void

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

            $platform_email = $configuration;

Missing function doc comment
Open

    public function getMailConfigurationValueFromFile(string $variable): ?string

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

        global $platform_email;

Missing class doc comment
Open

abstract class AbstractMigrationChamilo extends AbstractMigration

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

    protected function writeFile(string $filename, string $content): void

Missing function doc comment
Open

    public function __construct(Connection $connection, LoggerInterface $logger)

Missing function doc comment
Open

    public function getMailConfigurationValue(string $variable, array $configuration = []): mixed

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

        global $platform_email;

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

        if (isset($platform_email[$variable])) {

Missing function doc comment
Open

    public function fileExists($filePath): bool

Missing function doc comment
Open

    public function getAdmin(): User

Missing function doc comment
Open

    public function fixItemProperty(

Missing function doc comment
Open

    public function findCourse(int $id): ?Course

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

        $settingValue = $this->getConfigurationValue($variable, $platform_email);

Missing function doc comment
Open

    public function addLegacyFileToResource(

Add a single space around assignment operators
Open

declare(strict_types=1);

Missing function doc comment
Open

    public function setContainer(?ContainerInterface $container = null): void

Missing function doc comment
Open

    public function findSession(int $id): ?Session

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

    public function setEntityManager(EntityManagerInterface $entityManager): void

Missing function doc comment
Open

    public function adminExist(): bool

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

            return $platform_email[$variable];

The variable $_configuration is not named in camelCase.
Open

    public function getConfigurationValue($variable, $configuration = null)
    {
        global $_configuration;

        if (isset($configuration)) {

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

The variable $platform_email is not named in camelCase.
Open

    public function getMailConfigurationValueFromFile(string $variable): ?string
    {
        global $platform_email;

        $rootPath = $this->container->get('kernel')->getProjectDir();

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

The variable $platform_email is not named in camelCase.
Open

    public function getMailConfigurationValue(string $variable, array $configuration = []): mixed
    {
        global $platform_email;

        if ($configuration) {

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

The variable $platform_email is not named in camelCase.
Open

    public function getMailConfigurationValue(string $variable, array $configuration = []): mixed
    {
        global $platform_email;

        if ($configuration) {

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

The variable $platform_email is not named in camelCase.
Open

    public function getMailConfigurationValue(string $variable, array $configuration = []): mixed
    {
        global $platform_email;

        if ($configuration) {

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

The variable $platform_email is not named in camelCase.
Open

    public function getMailConfigurationValueFromFile(string $variable): ?string
    {
        global $platform_email;

        $rootPath = $this->container->get('kernel')->getProjectDir();

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

The variable $_configuration is not named in camelCase.
Open

    public function getConfigurationValue($variable, $configuration = null)
    {
        global $_configuration;

        if (isset($configuration)) {

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

The variable $platform_email is not named in camelCase.
Open

    public function getMailConfigurationValue(string $variable, array $configuration = []): mixed
    {
        global $platform_email;

        if ($configuration) {

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

The variable $_configuration is not named in camelCase.
Open

    public function getConfigurationValue($variable, $configuration = null)
    {
        global $_configuration;

        if (isset($configuration)) {

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

The variable $_configuration is not named in camelCase.
Open

    public function getConfigurationValue($variable, $configuration = null)
    {
        global $_configuration;

        if (isset($configuration)) {

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