chamilo/chamilo-lms

View on GitHub
public/main/inc/lib/SortableTableFromArray.php

Summary

Maintainability
A
0 mins
Test Coverage

Avoid unused parameters such as '$column'.
Open

        $column = null,

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 parameters such as '$direction'.
Open

        $direction = null,

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 parameters such as '$perPage'.
Open

        $perPage = null,

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

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

        } else {
            $content = $this->table_data;
        }

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

        } else {
            if (!empty($this->table_data)) {
                return count($this->table_data);
            }

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

    public function __construct(
        $table_data,
        $default_column = 1,
        $default_items_per_page = 20,
        $tableName = 'tablename',

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

    public function __construct(
        $table_data,
        $default_column = 1,
        $default_items_per_page = 20,
        $tableName = 'tablename',

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

class SortableTableFromArray extends SortableTable
{
    /**
     * The array containing all data for this table.
     */

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

    public function __construct(
        $table_data,
        $default_column = 1,
        $default_items_per_page = 20,
        $tableName = 'tablename',

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

    public function __construct(
        $table_data,
        $default_column = 1,
        $default_items_per_page = 20,
        $tableName = 'tablename',

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 "table_data" is not in valid camel caps format
Open

                return count($this->table_data);

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

            $default_items_per_page,

Method name "SortableTableFromArray::get_table_data" is not in camel caps format
Open

    public function get_table_data(

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

            $get_total_number_function,

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

        $this->table_data = $table_data;

Method name "SortableTableFromArray::get_total_number_of_items" is not in camel caps format
Open

    public function get_total_number_of_items()

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

        return array_slice($content, $from, $this->per_page);

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

            if (!empty($this->table_data)) {

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

        $get_total_number_function = null,

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

                $this->table_data,

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

        $default_items_per_page = 20,

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

        $this->table_data = $table_data;

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

        if (isset($this->total_number_of_items) && !empty($this->total_number_of_items)) {

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

        $default_column = 1,

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

            $content = $this->table_data;

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

            return $this->total_number_of_items;

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

    public $table_data;

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

        $table_data,

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

            $default_column,

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

        if (isset($this->total_number_of_items) && !empty($this->total_number_of_items)) {

The variable $get_total_number_function is not named in camelCase.
Open

    public function __construct(
        $table_data,
        $default_column = 1,
        $default_items_per_page = 20,
        $tableName = 'tablename',

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

    public function __construct(
        $table_data,
        $default_column = 1,
        $default_items_per_page = 20,
        $tableName = 'tablename',

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

    public function __construct(
        $table_data,
        $default_column = 1,
        $default_items_per_page = 20,
        $tableName = 'tablename',

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

    public function __construct(
        $table_data,
        $default_column = 1,
        $default_items_per_page = 20,
        $tableName = 'tablename',

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

    public function get_table_data(
        $from = 1,
        $perPage = null,
        $column = null,
        $direction = null,

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

    public function get_total_number_of_items()
    {
        if (isset($this->total_number_of_items) && !empty($this->total_number_of_items)) {
            return $this->total_number_of_items;
        } else {

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