chamilo/chamilo-lms

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

Summary

Maintainability
A
0 mins
Test Coverage

Missing class import via use statement (line '283', column '26').
Open

        $promotion = new \Chamilo\CoreBundle\Entity\Promotion();
Severity: Minor
Found in public/main/inc/lib/promotion.lib.php by phpmd

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 '235', column '23').
Open

        $career = new Career();
Severity: Minor
Found in public/main/inc/lib/promotion.lib.php by phpmd

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 '207', column '21').
Open

        $form = new FormValidator('promotion', 'post', $url);
Severity: Minor
Found in public/main/inc/lib/promotion.lib.php by phpmd

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

        } else {
            return false;
        }
Severity: Minor
Found in public/main/inc/lib/promotion.lib.php by phpmd

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

        } else {
            $form->addButtonCreate(get_lang('Add'), 'submit');
        }
Severity: Minor
Found in public/main/inc/lib/promotion.lib.php by phpmd

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

            } else {
                $pid = $this->save($new);
            }
Severity: Minor
Found in public/main/inc/lib/promotion.lib.php by phpmd

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

    public function save($params, $showQuery = false)
Severity: Minor
Found in public/main/inc/lib/promotion.lib.php by phpmd

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

    public function get_all_promotions_by_career_id($career_id, $order = false)
    {
        return Database::select(
            '*',
            $this->table,
Severity: Minor
Found in public/main/inc/lib/promotion.lib.php by phpmd

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

    public function copy($id, $career_id = null, $copy_sessions = false)
    {
        $pid = false;
        $promotion = $this->get($id);
        if (!empty($promotion)) {
Severity: Minor
Found in public/main/inc/lib/promotion.lib.php by phpmd

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

    public function copy($id, $career_id = null, $copy_sessions = false)
    {
        $pid = false;
        $promotion = $this->get($id);
        if (!empty($promotion)) {
Severity: Minor
Found in public/main/inc/lib/promotion.lib.php by phpmd

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

    public function update_all_sessions_status_by_promotion_id(
        $promotion_id,
        $status
    ) {
        $sessionList = SessionManager::get_all_sessions_by_promotion($promotion_id);
Severity: Minor
Found in public/main/inc/lib/promotion.lib.php by phpmd

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 "Promotion::get_all_promotions_by_career_id" is not in camel caps format
Open

    public function get_all_promotions_by_career_id($career_id, $order = false)

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

            $career_list,

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

        $form->addSelect('status', get_lang('Status'), $status_list);

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

    public function get_all_promotions_by_career_id($career_id, $order = false)

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

        $promotion_id,

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

        $sessionList = SessionManager::get_all_sessions_by_promotion($promotion_id);

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

                        if (!empty($career_id)) {

Missing parameter name
Open

     * @param   int     career id

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

                        foreach ($session_list as $item) {

Expected 14 spaces after parameter type; 1 found
Open

     * @param bool $order

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

                'where' => ['career_id = ?' => $career_id],

Method name "Promotion::return_form" is not in camel caps format
Open

    public function return_form($url, $action = 'add')

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

            $career_list[$item['id']] = $item['name'];

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

                            $val = (int) $career_id;

Method name "Promotion::get_status_list" is not in camel caps format
Open

    public function get_status_list(): array

Method name "Promotion::get_count" is not in camel caps format
Open

    public function get_count()

Missing parameter name
Open

     * @param   int     Promotion ID

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

    public function copy($id, $career_id = null, $copy_sessions = false)

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

    public function copy($id, $career_id = null, $copy_sessions = false)

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

                        $new_session_list = [];

Method name "Promotion::update_all_sessions_status_by_promotion_id" is not in camel caps format
Open

    public function update_all_sessions_status_by_promotion_id(

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

            if ($copy_sessions) {

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

                $session_list = SessionManager::get_all_sessions_by_promotion($id);

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

                if (!empty($session_list)) {

Missing parameter name
Open

     * @param   int     Career ID, in case we want to change it

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

                            $new_session_list[] = $sid;

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

                                $new_session_list

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

        $career_list = [];

Missing parameter name
Open

     * @param   bool     Whether or not to copy the sessions inside

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

                        if (!empty($new_session_list)) {

Missing function doc comment
Open

    public function get_status_list(): array

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

        $status_list = $this->get_status_list();

The variable $promotion_id is not named in camelCase.
Open

    public function update_all_sessions_status_by_promotion_id(
        $promotion_id,
        $status
    ) {
        $sessionList = SessionManager::get_all_sessions_by_promotion($promotion_id);
Severity: Minor
Found in public/main/inc/lib/promotion.lib.php by phpmd

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

    public function return_form($url, $action = 'add')
    {
        $form = new FormValidator('promotion', 'post', $url);
        // Setting the form elements
        $header = get_lang('Add');
Severity: Minor
Found in public/main/inc/lib/promotion.lib.php by phpmd

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

    public function return_form($url, $action = 'add')
    {
        $form = new FormValidator('promotion', 'post', $url);
        // Setting the form elements
        $header = get_lang('Add');
Severity: Minor
Found in public/main/inc/lib/promotion.lib.php by phpmd

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

    public function copy($id, $career_id = null, $copy_sessions = false)
    {
        $pid = false;
        $promotion = $this->get($id);
        if (!empty($promotion)) {
Severity: Minor
Found in public/main/inc/lib/promotion.lib.php by phpmd

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

    public function return_form($url, $action = 'add')
    {
        $form = new FormValidator('promotion', 'post', $url);
        // Setting the form elements
        $header = get_lang('Add');
Severity: Minor
Found in public/main/inc/lib/promotion.lib.php by phpmd

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

    public function copy($id, $career_id = null, $copy_sessions = false)
    {
        $pid = false;
        $promotion = $this->get($id);
        if (!empty($promotion)) {
Severity: Minor
Found in public/main/inc/lib/promotion.lib.php by phpmd

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

    public function get_all_promotions_by_career_id($career_id, $order = false)
    {
        return Database::select(
            '*',
            $this->table,
Severity: Minor
Found in public/main/inc/lib/promotion.lib.php by phpmd

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

    public function copy($id, $career_id = null, $copy_sessions = false)
    {
        $pid = false;
        $promotion = $this->get($id);
        if (!empty($promotion)) {
Severity: Minor
Found in public/main/inc/lib/promotion.lib.php by phpmd

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

    public function return_form($url, $action = 'add')
    {
        $form = new FormValidator('promotion', 'post', $url);
        // Setting the form elements
        $header = get_lang('Add');
Severity: Minor
Found in public/main/inc/lib/promotion.lib.php by phpmd

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

    public function copy($id, $career_id = null, $copy_sessions = false)
    {
        $pid = false;
        $promotion = $this->get($id);
        if (!empty($promotion)) {
Severity: Minor
Found in public/main/inc/lib/promotion.lib.php by phpmd

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

    public function copy($id, $career_id = null, $copy_sessions = false)
    {
        $pid = false;
        $promotion = $this->get($id);
        if (!empty($promotion)) {
Severity: Minor
Found in public/main/inc/lib/promotion.lib.php by phpmd

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

    public function copy($id, $career_id = null, $copy_sessions = false)
    {
        $pid = false;
        $promotion = $this->get($id);
        if (!empty($promotion)) {
Severity: Minor
Found in public/main/inc/lib/promotion.lib.php by phpmd

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

    public function copy($id, $career_id = null, $copy_sessions = false)
    {
        $pid = false;
        $promotion = $this->get($id);
        if (!empty($promotion)) {
Severity: Minor
Found in public/main/inc/lib/promotion.lib.php by phpmd

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

    public function return_form($url, $action = 'add')
    {
        $form = new FormValidator('promotion', 'post', $url);
        // Setting the form elements
        $header = get_lang('Add');
Severity: Minor
Found in public/main/inc/lib/promotion.lib.php by phpmd

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

    public function copy($id, $career_id = null, $copy_sessions = false)
    {
        $pid = false;
        $promotion = $this->get($id);
        if (!empty($promotion)) {
Severity: Minor
Found in public/main/inc/lib/promotion.lib.php by phpmd

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

    public function copy($id, $career_id = null, $copy_sessions = false)
    {
        $pid = false;
        $promotion = $this->get($id);
        if (!empty($promotion)) {
Severity: Minor
Found in public/main/inc/lib/promotion.lib.php by phpmd

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

    public function copy($id, $career_id = null, $copy_sessions = false)
    {
        $pid = false;
        $promotion = $this->get($id);
        if (!empty($promotion)) {
Severity: Minor
Found in public/main/inc/lib/promotion.lib.php by phpmd

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

    public function get_all_promotions_by_career_id($career_id, $order = false)
    {
        return Database::select(
            '*',
            $this->table,
Severity: Minor
Found in public/main/inc/lib/promotion.lib.php by phpmd

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

    public function update_all_sessions_status_by_promotion_id(
        $promotion_id,
        $status
    ) {
        $sessionList = SessionManager::get_all_sessions_by_promotion($promotion_id);
Severity: Minor
Found in public/main/inc/lib/promotion.lib.php by phpmd

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

    public function return_form($url, $action = 'add')
    {
        $form = new FormValidator('promotion', 'post', $url);
        // Setting the form elements
        $header = get_lang('Add');
Severity: Minor
Found in public/main/inc/lib/promotion.lib.php by phpmd

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

    public function get_count()
    {
        $row = Database::select(
            'count(*) as count',
            $this->table,
Severity: Minor
Found in public/main/inc/lib/promotion.lib.php by phpmd

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

    public function get_status_list(): array
    {
        return [
            PromotionEntity::PROMOTION_STATUS_ACTIVE => get_lang('active'),
            PromotionEntity::PROMOTION_STATUS_INACTIVE => get_lang('inactive'),
Severity: Minor
Found in public/main/inc/lib/promotion.lib.php by phpmd

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