chamilo/chamilo-lms

View on GitHub
public/main/gradebook/lib/fe/userform.class.php

Summary

Maintainability
A
0 mins
Test Coverage

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

        } else {
            $this->addElement('static', 'lname', get_lang('Last name'), $this->user_info['lastname']);
            $this->addElement('static', 'fname', get_lang('First name'), $this->user_info['firstname']);
        }

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

    public function __construct($form_type, $user, $form_name, $method = 'post', $action = null)
    {
        parent::__construct($form_name, $method, $action);
        $this->form_type = $form_type;
        if (isset($user)) {

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

    public function __construct($form_type, $user, $form_name, $method = 'post', $action = null)
    {
        parent::__construct($form_name, $method, $action);
        $this->form_type = $form_type;
        if (isset($user)) {

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

            $this->addElement('static', 'fname', get_lang('First name'), $this->user_info['firstname']);

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

        } elseif (self::TYPE_SIMPLE_SEARCH == $this->form_type) {

Missing function doc comment
Open

    public function setDefaults($defaultValues = [], $filter = null)

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

            $this->addElement('static', 'lname', get_lang('Last name'), $this->user_info['lastname']);

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

        if (self::TYPE_USER_INFO == $this->form_type) {

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

            '<a href="mailto:'.$this->user_info['email'].'">'.$this->user_info['email'].'</a>'

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

        $this->addElement('static', 'ofcode', get_lang('Code'), $this->user_info['official_code']);

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

        parent::__construct($form_name, $method, $action);

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

        $this->addElement('static', 'phone', get_lang('Phone'), $this->user_info['phone']);

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

    public function __construct($form_type, $user, $form_name, $method = 'post', $action = null)

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

        $this->form_type = $form_type;

Missing function doc comment
Open

    public function display()

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

        $this->form_type = $form_type;

Method name "UserForm::build_user_info_form" is not in camel caps format
Open

    protected function build_user_info_form()

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

    public function __construct($form_type, $user, $form_name, $method = 'post', $action = null)

Method name "UserForm::build_simple_search" is not in camel caps format
Open

    protected function build_simple_search()

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

            '<a href="mailto:'.$this->user_info['email'].'">'.$this->user_info['email'].'</a>'

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

            $this->user_info = $user;

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

            $this->addElement('static', 'lname', get_lang('Last name'), $this->user_info['lastname']);

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

        $this->addElement('static', 'uname', get_lang('Username'), $this->user_info['username']);

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

            $this->addElement('static', 'fname', get_lang('First name'), $this->user_info['firstname']);

The variable $form_type is not named in camelCase.
Open

    public function __construct($form_type, $user, $form_name, $method = 'post', $action = null)
    {
        parent::__construct($form_name, $method, $action);
        $this->form_type = $form_type;
        if (isset($user)) {

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

    public function __construct($form_type, $user, $form_name, $method = 'post', $action = null)
    {
        parent::__construct($form_name, $method, $action);
        $this->form_type = $form_type;
        if (isset($user)) {

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

    protected function build_simple_search()
    {
        if (isset($_GET['search']) && (!empty($_GET['search']))) {
            $this->setDefaults([
                'keyword' => Security::remove_XSS($_GET['search']),

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

    protected function build_user_info_form()
    {
        if (api_is_western_name_order()) {
            $this->addElement('static', 'fname', get_lang('First name'), $this->user_info['firstname']);
            $this->addElement('static', 'lname', get_lang('Last name'), $this->user_info['lastname']);

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