chamilo/chamilo-lms

View on GitHub
src/CoreBundle/Settings/SettingsManager.php

Summary

Maintainability
A
0 mins
Test Coverage

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

class SettingsManager implements SettingsManagerInterface
{
    protected ?AccessUrl $url = null;

    protected ServiceRegistryInterface $schemaRegistry;

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

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

        } else {
            return $settings;
        }

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

        } else {
            $query = $this->repository->createQueryBuilder('s')
                ->where('s.variable LIKE :keyword')
                ->setParameter('keyword', "%{$keyword}%")
            ;

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

                    } else {
                        $knownParameters[$parameter] = $transformer->reverseTransform($knownParameters[$parameter]);
                    }

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

            } else {
                $parameter = (new SettingsCurrent())
                    ->setVariable($name)
                    ->setCategory($simpleCategoryName)
                    ->setTitle($name)

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

                } else {
                    $parameters[$parameter] = $transformer->reverseTransform($parameters[$parameter]);
                }

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

            } else {
                $message = \sprintf('Parameter must be in format "category.name", "%s" given.', $name);

                throw new InvalidArgumentException($message);
            }

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

            } else {
                $parameter = (new SettingsCurrent())
                    ->setVariable($name)
                    ->setCategory($simpleCategoryName)
                    ->setTitle($name)

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

            foreach ($parameters as $name => $value) {

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

    public function load(string $schemaAlias, ?string $namespace = null, bool $ignoreUnknown = true): SettingsInterface

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 getUrl(): ?AccessUrl

Space before opening parenthesis of function call prohibited
Open

                fn ($key): bool => $settingsBuilder->isDefined($key),

Add a single space around assignment operators
Open

declare(strict_types=1);

Missing function doc comment
Open

    public function updateSchemas(AccessUrl $url): void

Missing function doc comment
Open

    public function setUrl(AccessUrl $url): void

Missing function doc comment
Open

    public function loadAll(): void

Missing function doc comment
Open

    public function __construct(

Missing function doc comment
Open

    public function updateSetting(string $name, $value): void

Missing function doc comment
Open

    public function installSchemas(AccessUrl $url): void

Missing function doc comment
Open

    public function convertServiceToNameSpace(string $category): string

Missing function doc comment
Open

    public function convertNameSpaceToService(string $category): string

Missing function doc comment
Open

    public function load(string $schemaAlias, ?string $namespace = null, bool $ignoreUnknown = true): SettingsInterface

Missing function doc comment
Open

    public function update(SettingsInterface $settings): void

Space before opening parenthesis of function call prohibited
Open

                fn ($key): bool => $settingsBuilder->isDefined($key),

There are no issues that match your filters.

Category
Status