chamilo/chamilo-lms

View on GitHub
public/plugin/lti_provider/LtiProviderPlugin.php

Summary

Maintainability
A
0 mins
Test Coverage

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

class LtiProviderPlugin extends Plugin
{
    public const TABLE_PLATFORM = 'plugin_lti_provider_platform';
    public const LAUNCH_PATH = 'lti_provider/tool/start.php';
    public const LOGIN_PATH = 'lti_provider/tool/login.php';

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

Missing class import via use statement (line '479', column '36').
Open

                ->setStartDate(new DateTime())

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

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

Missing class import via use statement (line '543', column '20').
Open

        return new SimpleXMLElement($request);

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

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

Missing class import via use statement (line '167', column '25').
Open

            $list = new LearnpathList(

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

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

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

        } else {
            if ($platformKey) {
                $em->remove($platformKey);
            }
        }

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

        } else {
            $objResult = new Result();
            $objResult
                ->setIssuer($values['issuer'])
                ->setUserId($values['user_id'])

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

        } else {
            $pkHtml = $this->get_lang('GenerateKeyPairInfo');
        }

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

            foreach ($exerciseList as $key => $exercise) {

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 private methods such as 'getRequestXmlElement'.
Open

    private function getRequestXmlElement(): ?SimpleXMLElement
    {
        $request = file_get_contents("php://input");

        if (empty($request)) {

UnusedPrivateMethod

Since: 0.2

Unused Private Method detects when a private method is declared but is unused.

Example

class Something
{
    private function foo() {} // unused
}

Source https://phpmd.org/rules/unusedcode.html#unusedprivatemethod

Missing parameter name
Open

     * @param $courseCode

Missing parameter name
Open

     * @param $label

Missing function doc comment
Open

    public function getToolProviderVars($clientId): array

Missing function doc comment
Open

    public function trimParams(array &$params)

Missing parameter name
Open

     * @param $toolId

Missing parameter name
Open

     * @param $userId

Method name "LtiProviderPlugin::get_name" is not in camel caps format
Open

    public function get_name(): string

Missing parameter name
Open

     * @param $id

Missing parameter name
Open

     * @param $value

Missing parameter name
Open

     * @param $startDate

Missing parameter name
Open

     * @param $endDate

Missing function doc comment
Open

    public function saveResult($values, $ltiLaunchId = null)

The method get_name is not named in camelCase.
Open

    public function get_name(): string
    {
        return 'lti_provider';
    }

CamelCaseMethodName

Since: 0.2

It is considered best practice to use the camelCase notation to name methods.

Example

class ClassName {
    public function get_name() {
    }
}

Source

There are no issues that match your filters.

Category
Status