chamilo/chamilo-lms

View on GitHub
public/main/lp/learnpathList.class.php

Summary

Maintainability
A
0 mins
Test Coverage

The method __construct() has an NPath complexity of 7704. The configured NPath complexity threshold is 200.
Open

    public function __construct(
        $user_id,
        $courseInfo = [],
        $session_id = 0,
        $order_by = null,

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

            } else {
                $categoryFilter = ' resource.category IS NULL ';
            }

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

            $resourceNode = $lp->getResourceNode();

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

The parameter $check_publication_dates is not named in camelCase.
Open

    public function __construct(
        $user_id,
        $courseInfo = [],
        $session_id = 0,
        $order_by = null,

CamelCaseParameterName

Since: 0.2

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

Example

class ClassName {
    public function doSomething($user_name) {
    }
}

Source

The parameter $user_id is not named in camelCase.
Open

    public function __construct(
        $user_id,
        $courseInfo = [],
        $session_id = 0,
        $order_by = null,

CamelCaseParameterName

Since: 0.2

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

Example

class ClassName {
    public function doSomething($user_name) {
    }
}

Source

The property $alpha_list is not named in camelCase.
Open

class LearnpathList
{
    // Holds a flat list of learnpaths data from the database.
    public $list = [];
    // Holds a flat list of learnpaths sorted by alphabetical name order.

CamelCasePropertyName

Since: 0.2

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

Example

class ClassName {
    protected $property_name;
}

Source

The property $course_code is not named in camelCase.
Open

class LearnpathList
{
    // Holds a flat list of learnpaths data from the database.
    public $list = [];
    // Holds a flat list of learnpaths sorted by alphabetical name order.

CamelCasePropertyName

Since: 0.2

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

Example

class ClassName {
    protected $property_name;
}

Source

The property $user_id is not named in camelCase.
Open

class LearnpathList
{
    // Holds a flat list of learnpaths data from the database.
    public $list = [];
    // Holds a flat list of learnpaths sorted by alphabetical name order.

CamelCasePropertyName

Since: 0.2

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

Example

class ClassName {
    protected $property_name;
}

Source

The parameter $course_code is not named in camelCase.
Open

    public static function get_course_lessons($course_code, $session_id)
    {
        $table = Database::get_course_table(TABLE_LP_MAIN);
        $course = api_get_course_info($course_code);
        // @todo AND session_id = %s ?

CamelCaseParameterName

Since: 0.2

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

Example

class ClassName {
    public function doSomething($user_name) {
    }
}

Source

The parameter $session_id is not named in camelCase.
Open

    public static function get_course_lessons($course_code, $session_id)
    {
        $table = Database::get_course_table(TABLE_LP_MAIN);
        $course = api_get_course_info($course_code);
        // @todo AND session_id = %s ?

CamelCaseParameterName

Since: 0.2

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

Example

class ClassName {
    public function doSomething($user_name) {
    }
}

Source

The parameter $order_by is not named in camelCase.
Open

    public function __construct(
        $user_id,
        $courseInfo = [],
        $session_id = 0,
        $order_by = null,

CamelCaseParameterName

Since: 0.2

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

Example

class ClassName {
    public function doSomething($user_name) {
    }
}

Source

The parameter $session_id is not named in camelCase.
Open

    public function __construct(
        $user_id,
        $courseInfo = [],
        $session_id = 0,
        $order_by = null,

CamelCaseParameterName

Since: 0.2

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

Example

class ClassName {
    public function doSomething($user_name) {
    }
}

Source

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

                        $user_id,

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

    public static function get_course_lessons($course_code, $session_id)

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

        $user_id,

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

        $course = api_get_course_entity($course_id);

Member variable "user_id" is not in valid camel caps format
Open

    public $user_id;

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

            $qb->addOrderBy($order_by);

Expected 2 spaces after parameter name; 1 found
Open

     *  @param int  $session_id Id of session

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

        $course = api_get_course_info($course_code);

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

        if (!empty($order_by)) {

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

        $course_id = $courseInfo['real_id'];

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

        $session = api_get_session_entity($session_id);

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

        if ($check_publication_dates) {

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

        $sql_query = sprintf($sql, $course['real_id']);

Member variable "alpha_list" is not in valid camel caps format
Open

    public $alpha_list = [];

Member variable "course_code" is not in valid camel caps format
Open

    public $course_code;

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

        $this->user_id = $user_id;

Expected 4 spaces after parameter type; 2 found
Open

     *  @param int  $session_id Id of session

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

        $result = Database::query($sql_query);

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

        $order_by = null,

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

        $this->alpha_list = $names;

Method name "LearnpathList::get_course_lessons" is not in camel caps format
Open

    public static function get_course_lessons($course_code, $session_id)

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

        $this->user_id = $user_id;

Method name "LearnpathList::get_flat_list" is not in camel caps format
Open

    public function get_flat_list()

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

        $session_id = 0,

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

            if (api_get_item_visibility($course, 'learnpath', $row['id'], $session_id)) {

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

        $check_publication_dates = false,

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

    public static function get_course_lessons($course_code, $session_id)

The variable $user_id is not named in camelCase.
Open

    public function __construct(
        $user_id,
        $courseInfo = [],
        $session_id = 0,
        $order_by = null,

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 $sql_query is not named in camelCase.
Open

    public static function get_course_lessons($course_code, $session_id)
    {
        $table = Database::get_course_table(TABLE_LP_MAIN);
        $course = api_get_course_info($course_code);
        // @todo AND session_id = %s ?

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 $order_by is not named in camelCase.
Open

    public function __construct(
        $user_id,
        $courseInfo = [],
        $session_id = 0,
        $order_by = null,

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 $session_id is not named in camelCase.
Open

    public static function get_course_lessons($course_code, $session_id)
    {
        $table = Database::get_course_table(TABLE_LP_MAIN);
        $course = api_get_course_info($course_code);
        // @todo AND session_id = %s ?

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 $order_by is not named in camelCase.
Open

    public function __construct(
        $user_id,
        $courseInfo = [],
        $session_id = 0,
        $order_by = null,

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 $session_id is not named in camelCase.
Open

    public function __construct(
        $user_id,
        $courseInfo = [],
        $session_id = 0,
        $order_by = null,

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 $user_id is not named in camelCase.
Open

    public function __construct(
        $user_id,
        $courseInfo = [],
        $session_id = 0,
        $order_by = null,

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 $course_code is not named in camelCase.
Open

    public static function get_course_lessons($course_code, $session_id)
    {
        $table = Database::get_course_table(TABLE_LP_MAIN);
        $course = api_get_course_info($course_code);
        // @todo AND session_id = %s ?

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 $sql_query is not named in camelCase.
Open

    public static function get_course_lessons($course_code, $session_id)
    {
        $table = Database::get_course_table(TABLE_LP_MAIN);
        $course = api_get_course_info($course_code);
        // @todo AND session_id = %s ?

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 $course_id is not named in camelCase.
Open

    public function __construct(
        $user_id,
        $courseInfo = [],
        $session_id = 0,
        $order_by = null,

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 $check_publication_dates is not named in camelCase.
Open

    public function __construct(
        $user_id,
        $courseInfo = [],
        $session_id = 0,
        $order_by = null,

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 $course_id is not named in camelCase.
Open

    public function __construct(
        $user_id,
        $courseInfo = [],
        $session_id = 0,
        $order_by = null,

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 method get_flat_list is not named in camelCase.
Open

    public function get_flat_list()
    {
        return $this->list;
    }

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

The method get_course_lessons is not named in camelCase.
Open

    public static function get_course_lessons($course_code, $session_id)
    {
        $table = Database::get_course_table(TABLE_LP_MAIN);
        $course = api_get_course_info($course_code);
        // @todo AND session_id = %s ?

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