chamilo/chamilo-lms

View on GitHub
public/plugin/learning_calendar/LearningCalendarPlugin.php

Summary

Maintainability
A
0 mins
Test Coverage

Missing class import via use statement (line '176', column '27').
Open

        $extraField = new ExtraField('course');

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 '396', column '27').
Open

        $extraField = new ExtraField('lp_item');

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 '169', column '27').
Open

        $extraField = new ExtraField('lp_item');

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 '428', column '27').
Open

        $extraField = new ExtraFieldValue('lp_item');

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 '138', column '27').
Open

        $extraField = new ExtraField('course');

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 '743', column '27').
Open

        $extraField = new ExtraField('lp_item');

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 '126', column '27').
Open

        $extraField = new ExtraField('lp_item');

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 '411', column '35').
Open

                $extraField = new ExtraFieldValue('lp_item');

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 '401', column '35').
Open

                $extraField = new ExtraFieldValue('lp_item');

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

            } else {
                $newValue = 1 === (int) $itemInfo['value'] ? 0 : 1;
                $extraField = new ExtraFieldValue('lp_item');
                $params = [
                    'id' => $itemInfo['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 toogleDayType uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            } else {
                $params = [
                    'type' => $currentType,
                ];
                Database::update(

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

        } else {
            $userId = api_get_user_id();
            $sql = "SELECT * FROM learning_calendar WHERE author_id = $userId";
        }

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

        } else {
            $userId = api_get_user_id();
            $sql = "select count(*) as count FROM learning_calendar WHERE author_id = $userId";
        }

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

        } else {
            $params = [
                'user_id' => $userId,
                'control_date' => $date,
                'control_value' => $value,

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

            } else {
                $courseAndSessionCondition[] = "
                    (
                        ((l.session_id = 0 OR l.session_id is NULL) OR l.session_id = $sessionId) AND
                        i.c_id IN ('$courseListToString')

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

        } else {
            $params = [
                'title' => '',
                'calendar_id' => $calendarId,
                'start_date' => $startDate,

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

        foreach ($coursesAndSessions as $sessionId => $courseList) {

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

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

    public function get_name()

Missing function doc comment
Open

    public function getAddUserToCalendarForm(FormValidator &$form)

Missing function doc comment
Open

    public function setJavaScript()

Missing function doc comment
Open

    public function protectCalendar(array $calendarInfo)

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

    public function getForm(FormValidator &$form)

The method get_name is not named in camelCase.
Open

    public function get_name()
    {
        return 'learning_calendar';
    }

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