chamilo/chamilo-lms

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

Summary

Maintainability
A
0 mins
Test Coverage

Avoid using undefined variables such as '$languages' which will lead to PHP notices.
Open

            $languages[] = $legal[1];
Severity: Minor
Found in public/main/inc/lib/legal.lib.php by phpmd

UndefinedVariable

Since: 2.8.0

Detects when a variable is used that has not been defined before.

Example

class Foo
{
    private function bar()
    {
        // $message is undefined
        echo $message;
    }
}

Source https://phpmd.org/rules/cleancode.html#undefinedvariable

Missing class import via use statement (line '46', column '36').
Open

            $extraFieldValue = new ExtraFieldValue('terms_and_condition');
Severity: Minor
Found in public/main/inc/lib/legal.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 '403', column '32').
Open

        $extraFieldValue = new ExtraFieldValue('user');
Severity: Minor
Found in public/main/inc/lib/legal.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 '424', column '32').
Open

        $extraFieldValue = new ExtraFieldValue('user');
Severity: Minor
Found in public/main/inc/lib/legal.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 '109', column '33').
Open

        $extraFieldValues = new ExtraFieldValue('terms_and_condition');
Severity: Minor
Found in public/main/inc/lib/legal.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 add uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

                    } else {
                        // It means there's a new extra field that was not included before.
                        $changeList[] = $replace;
                    }
Severity: Minor
Found in public/main/inc/lib/legal.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 local variables such as '$languages'.
Open

            $languages[] = $legal[1];
Severity: Minor
Found in public/main/inc/lib/legal.lib.php by phpmd

UnusedLocalVariable

Since: 0.2

Detects when a local variable is declared and/or assigned, but not used.

Example

class Foo {
    public function doSomething()
    {
        $i = 5; // Unused
    }
}

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

Avoid unused parameters such as '$id'.
Open

    public static function delete($id)
Severity: Minor
Found in public/main/inc/lib/legal.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 $legal_id is not named in camelCase.
Open

    public static function get_type_of_terms_and_conditions($legal_id, $language_id)
    {
        $table = Database::get_main_table(TABLE_MAIN_LEGAL);
        $legal_id = (int) $legal_id;
        $language_id = (int) $language_id;
Severity: Minor
Found in public/main/inc/lib/legal.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 $number_of_items is not named in camelCase.
Open

    public static function get_legal_data($from, $number_of_items, $column)
    {
        $table = Database::get_main_table(TABLE_MAIN_LEGAL);
        $lang_table = Database::get_main_table(TABLE_MAIN_LANGUAGE);
        $from = (int) $from;
Severity: Minor
Found in public/main/inc/lib/legal.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 $term_preview is not named in camelCase.
Open

    public static function show_last_condition($term_preview)
    {
        $preview = '';
        switch ($term_preview['type']) {
            case 0:
Severity: Minor
Found in public/main/inc/lib/legal.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 $language_id is not named in camelCase.
Open

    public static function get_type_of_terms_and_conditions($legal_id, $language_id)
    {
        $table = Database::get_main_table(TABLE_MAIN_LEGAL);
        $legal_id = (int) $legal_id;
        $language_id = (int) $language_id;
Severity: Minor
Found in public/main/inc/lib/legal.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

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

                    <div id="legal-terms" class="scrollbar-inner">'.$term_preview['content'].'</div>

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

    public static function get_legal_data($from, $number_of_items, $column)

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

                WHERE id = $legal_id AND language_id = $language_id";

Method name "LegalManager::show_last_condition" is not in camel caps format
Open

    public static function show_last_condition($term_preview)

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

                INNER JOIN $lang_table l

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

    public static function get_type_of_terms_and_conditions($legal_id, $language_id)

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

                WHERE id = $legal_id AND language_id = $language_id";

Method name "LegalManager::get_last_version" is not in camel caps format
Open

    public static function get_last_version($language)

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

        switch ($term_preview['type']) {

Method name "LegalManager::get_legal_data" is not in camel caps format
Open

    public static function get_legal_data($from, $number_of_items, $column)

Method name "LegalManager::get_type_of_terms_and_conditions" is not in camel caps format
Open

    public static function get_type_of_terms_and_conditions($legal_id, $language_id)

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

        $legal_id = (int) $legal_id;

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

        $number_of_items = (int) $number_of_items;

Method name "LegalManager::get_last_condition" is not in camel caps format
Open

    public static function get_last_condition($language)

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

    public static function show_last_condition($term_preview)

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

        $language_id = (int) $language_id;

Expected 2 spaces after parameter name; 1 found
Open

     * @param int $userId The user to send legal terms to

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

    public static function get_type_of_terms_and_conditions($legal_id, $language_id)

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

        $legal_id = (int) $legal_id;

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

                if (!empty($term_preview['content'])) {

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

        $lang_table = Database::get_main_table(TABLE_MAIN_LANGUAGE);

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

        $number_of_items = (int) $number_of_items;

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

                LIMIT $from, $number_of_items ";

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

        $language_id = (int) $language_id;

The 'get_last_version()' method which returns a boolean should be named 'is...()' or 'has...()'
Open

    public static function get_last_version($language)
    {
        $table = Database::get_main_table(TABLE_MAIN_LEGAL);
        $language = (int) $language;
        $sql = "SELECT version FROM $table
Severity: Minor
Found in public/main/inc/lib/legal.lib.php by phpmd

BooleanGetMethodName

Since: 0.2

Looks for methods named 'getX()' with 'boolean' as the return type. The convention is to name these methods 'isX()' or 'hasX()'.

Example

class Foo {
    /**
     * @return boolean
     */
    public function getFoo() {} // bad
    /**
     * @return bool
     */
    public function isFoo(); // ok
    /**
     * @return boolean
     */
    public function getFoo($bar); // ok, unless checkParameterizedMethods=true
}

Source https://phpmd.org/rules/naming.html#booleangetmethodname

The variable $legal_id is not named in camelCase.
Open

    public static function get_type_of_terms_and_conditions($legal_id, $language_id)
    {
        $table = Database::get_main_table(TABLE_MAIN_LEGAL);
        $legal_id = (int) $legal_id;
        $language_id = (int) $language_id;
Severity: Minor
Found in public/main/inc/lib/legal.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 $language_id is not named in camelCase.
Open

    public static function get_type_of_terms_and_conditions($legal_id, $language_id)
    {
        $table = Database::get_main_table(TABLE_MAIN_LEGAL);
        $legal_id = (int) $legal_id;
        $language_id = (int) $language_id;
Severity: Minor
Found in public/main/inc/lib/legal.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 $language_id is not named in camelCase.
Open

    public static function get_type_of_terms_and_conditions($legal_id, $language_id)
    {
        $table = Database::get_main_table(TABLE_MAIN_LEGAL);
        $legal_id = (int) $legal_id;
        $language_id = (int) $language_id;
Severity: Minor
Found in public/main/inc/lib/legal.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 $legal_id is not named in camelCase.
Open

    public static function get_type_of_terms_and_conditions($legal_id, $language_id)
    {
        $table = Database::get_main_table(TABLE_MAIN_LEGAL);
        $legal_id = (int) $legal_id;
        $language_id = (int) $language_id;
Severity: Minor
Found in public/main/inc/lib/legal.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 $legal_id is not named in camelCase.
Open

    public static function get_type_of_terms_and_conditions($legal_id, $language_id)
    {
        $table = Database::get_main_table(TABLE_MAIN_LEGAL);
        $legal_id = (int) $legal_id;
        $language_id = (int) $language_id;
Severity: Minor
Found in public/main/inc/lib/legal.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 $term_preview is not named in camelCase.
Open

    public static function show_last_condition($term_preview)
    {
        $preview = '';
        switch ($term_preview['type']) {
            case 0:
Severity: Minor
Found in public/main/inc/lib/legal.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 $term_preview is not named in camelCase.
Open

    public static function show_last_condition($term_preview)
    {
        $preview = '';
        switch ($term_preview['type']) {
            case 0:
Severity: Minor
Found in public/main/inc/lib/legal.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 $term_preview is not named in camelCase.
Open

    public static function show_last_condition($term_preview)
    {
        $preview = '';
        switch ($term_preview['type']) {
            case 0:
Severity: Minor
Found in public/main/inc/lib/legal.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 $lang_table is not named in camelCase.
Open

    public static function get_legal_data($from, $number_of_items, $column)
    {
        $table = Database::get_main_table(TABLE_MAIN_LEGAL);
        $lang_table = Database::get_main_table(TABLE_MAIN_LANGUAGE);
        $from = (int) $from;
Severity: Minor
Found in public/main/inc/lib/legal.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 $number_of_items is not named in camelCase.
Open

    public static function get_legal_data($from, $number_of_items, $column)
    {
        $table = Database::get_main_table(TABLE_MAIN_LEGAL);
        $lang_table = Database::get_main_table(TABLE_MAIN_LANGUAGE);
        $from = (int) $from;
Severity: Minor
Found in public/main/inc/lib/legal.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 $number_of_items is not named in camelCase.
Open

    public static function get_legal_data($from, $number_of_items, $column)
    {
        $table = Database::get_main_table(TABLE_MAIN_LEGAL);
        $lang_table = Database::get_main_table(TABLE_MAIN_LANGUAGE);
        $from = (int) $from;
Severity: Minor
Found in public/main/inc/lib/legal.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 $lang_table is not named in camelCase.
Open

    public static function get_legal_data($from, $number_of_items, $column)
    {
        $table = Database::get_main_table(TABLE_MAIN_LEGAL);
        $lang_table = Database::get_main_table(TABLE_MAIN_LANGUAGE);
        $from = (int) $from;
Severity: Minor
Found in public/main/inc/lib/legal.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 $language_id is not named in camelCase.
Open

    public static function get_type_of_terms_and_conditions($legal_id, $language_id)
    {
        $table = Database::get_main_table(TABLE_MAIN_LEGAL);
        $legal_id = (int) $legal_id;
        $language_id = (int) $language_id;
Severity: Minor
Found in public/main/inc/lib/legal.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 $number_of_items is not named in camelCase.
Open

    public static function get_legal_data($from, $number_of_items, $column)
    {
        $table = Database::get_main_table(TABLE_MAIN_LEGAL);
        $lang_table = Database::get_main_table(TABLE_MAIN_LANGUAGE);
        $from = (int) $from;
Severity: Minor
Found in public/main/inc/lib/legal.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_last_version is not named in camelCase.
Open

    public static function get_last_version($language)
    {
        $table = Database::get_main_table(TABLE_MAIN_LEGAL);
        $language = (int) $language;
        $sql = "SELECT version FROM $table
Severity: Minor
Found in public/main/inc/lib/legal.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_last_condition is not named in camelCase.
Open

    public static function get_last_condition($language)
    {
        $table = Database::get_main_table(TABLE_MAIN_LEGAL);
        $language = (int) $language;
        $sql = "SELECT * FROM $table
Severity: Minor
Found in public/main/inc/lib/legal.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_legal_data is not named in camelCase.
Open

    public static function get_legal_data($from, $number_of_items, $column)
    {
        $table = Database::get_main_table(TABLE_MAIN_LEGAL);
        $lang_table = Database::get_main_table(TABLE_MAIN_LANGUAGE);
        $from = (int) $from;
Severity: Minor
Found in public/main/inc/lib/legal.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_type_of_terms_and_conditions is not named in camelCase.
Open

    public static function get_type_of_terms_and_conditions($legal_id, $language_id)
    {
        $table = Database::get_main_table(TABLE_MAIN_LEGAL);
        $legal_id = (int) $legal_id;
        $language_id = (int) $language_id;
Severity: Minor
Found in public/main/inc/lib/legal.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 show_last_condition is not named in camelCase.
Open

    public static function show_last_condition($term_preview)
    {
        $preview = '';
        switch ($term_preview['type']) {
            case 0:
Severity: Minor
Found in public/main/inc/lib/legal.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