chamilo/chamilo-lms

View on GitHub
public/plugin/dashboard/block_global_info/block_global_info.class.php

Summary

Maintainability
A
0 mins
Test Coverage

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

                } else {
                    $class_tr = 'row_even';
                }

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

        } else {
            $data_table .= get_lang('ThereIsNoInformationAboutThePlatform');
        }

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 private fields such as '$courses'.
Open

    private $courses;

UnusedPrivateField

Since: 0.2

Detects when a private field is declared and/or assigned a value, but not used.

Example

class Something
{
    private static $FOO = 2; // Unused
    private $i = 5; // Unused
    private $j = 6;
    public function addOne()
    {
        return $this->j++;
    }
}

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

The property $user_id is not named in camelCase.
Open

class BlockGlobalInfo extends Block
{
    private $user_id;
    private $courses;
    private $permission = [];

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

    public function is_block_visible_for_user($user_id)
    {
        $user_info = api_get_user_info($user_id);
        $user_status = $user_info['status'];
        $is_block_visible_for_user = false;

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)
    {
        $this->user_id = $user_id;
        $this->path = 'block_global_info';
    }

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

Method name "BlockGlobalInfo::is_block_visible_for_user" is not in camel caps format
Open

    public function is_block_visible_for_user($user_id)

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

                    $class_tr = 'row_odd';

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

    public function is_block_visible_for_user($user_id)

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

            foreach ($global_data as $data) {

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

                $data_table .= '<tr class="'.$class_tr.'">';

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

        return $data_table;

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

        $is_block_visible_for_user = false;

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

        return $is_block_visible_for_user;

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

            $data_table .= '</table>';

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

        $this->user_id = $user_id;

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

        $user_status = $user_info['status'];

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

        $this->user_id = $user_id;

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

                $data_table .= '<tr class="'.$class_tr.'">';

Method name "BlockGlobalInfo::get_global_information_data" is not in camel caps format
Open

    public function get_global_information_data()

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

    public function __construct($user_id)

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

        if (!empty($global_data)) {

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

            $data_table = '<table class="table table-bordered">';

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

                $data_table .= '</tr>';

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

                    $data_table .= '<td align="right">'.$cell.'</td>';

Method name "BlockGlobalInfo::get_block" is not in camel caps format
Open

    public function get_block()

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

        $global_data = $this->get_global_information_data();

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

        if (UserManager::is_admin($user_id) || in_array($user_status, $this->permission)) {

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

            $is_block_visible_for_user = true;

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

        $user_info = api_get_user_info($user_id);

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

        $user_status = $user_info['status'];

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

        $user_info = api_get_user_info($user_id);

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

        if (UserManager::is_admin($user_id) || in_array($user_status, $this->permission)) {

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

                    $class_tr = 'row_even';

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

        $data_table = null;

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

            $data_table .= get_lang('ThereIsNoInformationAboutThePlatform');

The variable $class_tr is not named in camelCase.
Open

    public function getContent()
    {
        $global_data = $this->get_global_information_data();
        $data_table = null;
        if (!empty($global_data)) {

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

    public function is_block_visible_for_user($user_id)
    {
        $user_info = api_get_user_info($user_id);
        $user_status = $user_info['status'];
        $is_block_visible_for_user = false;

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

    public function is_block_visible_for_user($user_id)
    {
        $user_info = api_get_user_info($user_id);
        $user_status = $user_info['status'];
        $is_block_visible_for_user = false;

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 is_block_visible_for_user($user_id)
    {
        $user_info = api_get_user_info($user_id);
        $user_status = $user_info['status'];
        $is_block_visible_for_user = false;

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

    public function getContent()
    {
        $global_data = $this->get_global_information_data();
        $data_table = null;
        if (!empty($global_data)) {

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

    public function is_block_visible_for_user($user_id)
    {
        $user_info = api_get_user_info($user_id);
        $user_status = $user_info['status'];
        $is_block_visible_for_user = false;

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

    public function getContent()
    {
        $global_data = $this->get_global_information_data();
        $data_table = null;
        if (!empty($global_data)) {

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

    public function getContent()
    {
        $global_data = $this->get_global_information_data();
        $data_table = null;
        if (!empty($global_data)) {

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

    public function is_block_visible_for_user($user_id)
    {
        $user_info = api_get_user_info($user_id);
        $user_status = $user_info['status'];
        $is_block_visible_for_user = false;

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 is_block_visible_for_user($user_id)
    {
        $user_info = api_get_user_info($user_id);
        $user_status = $user_info['status'];
        $is_block_visible_for_user = false;

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

    public function getContent()
    {
        $global_data = $this->get_global_information_data();
        $data_table = null;
        if (!empty($global_data)) {

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

    public function getContent()
    {
        $global_data = $this->get_global_information_data();
        $data_table = null;
        if (!empty($global_data)) {

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

    public function getContent()
    {
        $global_data = $this->get_global_information_data();
        $data_table = null;
        if (!empty($global_data)) {

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

    public function is_block_visible_for_user($user_id)
    {
        $user_info = api_get_user_info($user_id);
        $user_status = $user_info['status'];
        $is_block_visible_for_user = false;

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

    public function is_block_visible_for_user($user_id)
    {
        $user_info = api_get_user_info($user_id);
        $user_status = $user_info['status'];
        $is_block_visible_for_user = false;

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

    public function getContent()
    {
        $global_data = $this->get_global_information_data();
        $data_table = null;
        if (!empty($global_data)) {

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

    public function is_block_visible_for_user($user_id)
    {
        $user_info = api_get_user_info($user_id);
        $user_status = $user_info['status'];
        $is_block_visible_for_user = false;

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

    public function getContent()
    {
        $global_data = $this->get_global_information_data();
        $data_table = null;
        if (!empty($global_data)) {

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

    public function getContent()
    {
        $global_data = $this->get_global_information_data();
        $data_table = null;
        if (!empty($global_data)) {

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

    public function getContent()
    {
        $global_data = $this->get_global_information_data();
        $data_table = null;
        if (!empty($global_data)) {

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

    public function getContent()
    {
        $global_data = $this->get_global_information_data();
        $data_table = null;
        if (!empty($global_data)) {

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)
    {
        $this->user_id = $user_id;
        $this->path = 'block_global_info';
    }

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

    public function getContent()
    {
        $global_data = $this->get_global_information_data();
        $data_table = null;
        if (!empty($global_data)) {

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

    public function getContent()
    {
        $global_data = $this->get_global_information_data();
        $data_table = null;
        if (!empty($global_data)) {

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

    public function get_global_information_data()
    {
        // Two-dimensional array with data about the system
        $path = api_get_path(WEB_CODE_PATH);
        // Check total number of users

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

    public function is_block_visible_for_user($user_id)
    {
        $user_info = api_get_user_info($user_id);
        $user_status = $user_info['status'];
        $is_block_visible_for_user = false;

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

    public function get_block()
    {
        $column = 2;
        $data = [];
        $html = $this->getBlockCard(

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