chamilo/chamilo-lms

View on GitHub
public/plugin/dashboard/block_session/block_session.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 {
            $content .= get_lang('There is no available information about your sessions');
        }

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 {
                    $date = ' - ';
                }

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 {
                    $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 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_session';
        if ($this->is_block_visible_for_user($user_id)) {

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

class BlockSession extends Block
{
    private $user_id;
    private $sessions;
    private $permission = [DRH, SESSIONADMIN];

CamelCasePropertyName

Since: 0.2

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

Example

class ClassName {
    protected $property_name;
}

Source

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

            $sessions_table = '<table class="data_table" width:"95%">';

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

            $sessions_table .= '</table>';

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

        $this->user_id = $user_id;

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

            $this->sessions = SessionManager::get_sessions_followed_by_drh($user_id);

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

    public function is_block_visible_for_user($user_id)

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

            $sessions_table .= '<tr>

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

                $count_courses_in_session = count(Tracking::get_courses_list_from_session($session_id));

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

                $sessions_table .= '<tr class="'.$class_tr.'">

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

        $user_info = api_get_user_info($user_id);

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

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

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

                $count_courses_in_session = count(Tracking::get_courses_list_from_session($session_id));

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

        $user_info = api_get_user_info($user_id);

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

            $content .= $sessions_table;

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

        $user_status = $user_info['status'];

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

                    $class_tr = 'row_odd';

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

        $user_status = $user_info['status'];

Method name "BlockSession::get_number_of_sessions" is not in camel caps format
Open

    public function get_number_of_sessions()

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

                $session_id = (int) ($session['id']);

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

                    $class_tr = 'row_even';

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

                $sessions_table .= '<tr class="'.$class_tr.'">

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

            $is_block_visible_for_user = true;

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

                                        <td align="center">'.$count_courses_in_session.'</td>

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

    public function is_block_visible_for_user($user_id)

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

    public function get_block()

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

        $is_block_visible_for_user = false;

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

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

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

        $this->user_id = $user_id;

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

        return $is_block_visible_for_user;

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

        if ($this->is_block_visible_for_user($user_id)) {

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

    public function __construct($user_id)

The variable $user_id is not named in camelCase.
Open

    public function __construct($user_id)
    {
        $this->user_id = $user_id;
        $this->path = 'block_session';
        if ($this->is_block_visible_for_user($user_id)) {

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

    public function getContent()
    {
        $content = '';
        $sessions = $this->sessions;
        if (count($sessions) > 0) {

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

    public function getContent()
    {
        $content = '';
        $sessions = $this->sessions;
        if (count($sessions) > 0) {

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()
    {
        $content = '';
        $sessions = $this->sessions;
        if (count($sessions) > 0) {

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

    public function getContent()
    {
        $content = '';
        $sessions = $this->sessions;
        if (count($sessions) > 0) {

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

    public function getContent()
    {
        $content = '';
        $sessions = $this->sessions;
        if (count($sessions) > 0) {

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_session';
        if ($this->is_block_visible_for_user($user_id)) {

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()
    {
        $content = '';
        $sessions = $this->sessions;
        if (count($sessions) > 0) {

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()
    {
        $content = '';
        $sessions = $this->sessions;
        if (count($sessions) > 0) {

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_session';
        if ($this->is_block_visible_for_user($user_id)) {

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

    public function getContent()
    {
        $content = '';
        $sessions = $this->sessions;
        if (count($sessions) > 0) {

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

    public function getContent()
    {
        $content = '';
        $sessions = $this->sessions;
        if (count($sessions) > 0) {

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

    public function getContent()
    {
        $content = '';
        $sessions = $this->sessions;
        if (count($sessions) > 0) {

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

    public function getContent()
    {
        $content = '';
        $sessions = $this->sessions;
        if (count($sessions) > 0) {

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

    public function getContent()
    {
        $content = '';
        $sessions = $this->sessions;
        if (count($sessions) > 0) {

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

    public function get_number_of_sessions()
    {
        return count($this->sessions);
    }

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