chamilo/chamilo-lms

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

Summary

Maintainability
A
0 mins
Test Coverage

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

        } else {
            if (isset($link_object)) {
                $this->link_object = $link_object;
            }
        }

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

            } else {
                $select->addOption($link->get_type_name(), $linkType);
            }

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,
        $category_object,
        $link_object,
        $form_name,

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,
        $category_object,
        $link_object,
        $form_name,

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

class LinkForm extends FormValidator
{
    const TYPE_CREATE = 1;
    const TYPE_MOVE = 2;
    /** @var Category */

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

    public function __construct(
        $form_type,
        $category_object,
        $link_object,
        $form_name,

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

    public function __construct(
        $form_type,
        $category_object,
        $link_object,
        $form_name,

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

class LinkForm extends FormValidator
{
    const TYPE_CREATE = 1;
    const TYPE_MOVE = 2;
    /** @var Category */

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

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

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

        $form_type,

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

        $link_object,

Method name "LinkForm::build_create" is not in camel caps format
Open

    protected function build_create()

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

        } elseif (self::TYPE_MOVE == $form_type) {

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

            $this->category_object = $category_object;

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

            $this->category_object = $category_object;

Method name "LinkForm::build_move" is not in camel caps format
Open

    protected function build_move()

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

        $courseId = $this->category_object->getCourseId();

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

        if (isset($category_object)) {

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

            if (isset($link_object)) {

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

                $this->link_object = $link_object;

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

        if (self::TYPE_CREATE == $form_type) {

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

            '"'.$this->link_object->get_name().'" '

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

        foreach ($this->link_object->get_target_categories() as $cat) {

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

        $category_object,

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

                $this->link_object = $link_object;

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

        $form_name,

The variable $link_object is not named in camelCase.
Open

    public function __construct(
        $form_type,
        $category_object,
        $link_object,
        $form_name,

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

    public function __construct(
        $form_type,
        $category_object,
        $link_object,
        $form_name,

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

    public function __construct(
        $form_type,
        $category_object,
        $link_object,
        $form_name,

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

    public function __construct(
        $form_type,
        $category_object,
        $link_object,
        $form_name,

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

    public function __construct(
        $form_type,
        $category_object,
        $link_object,
        $form_name,

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

    public function __construct(
        $form_type,
        $category_object,
        $link_object,
        $form_name,

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,
        $category_object,
        $link_object,
        $form_name,

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

    protected function build_create()
    {
        $this->addHeader(get_lang('Add online activity'));
        $select = $this->addSelect(
            'select_link',

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

    protected function build_move()
    {
        $renderer = &$this->defaultRenderer();
        $renderer->setCustomElementTemplate('<span>{element}</span> ');
        $this->addElement(

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