chamilo/chamilo-lms

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

Summary

Maintainability
A
0 mins
Test Coverage

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

            } else {
                if (isset($item[$id]) && strip_tags($item[$id]) > strip_tags($array[$lowest_id][$id])) {
                    $lowest_id = $index;
                }
            }
Severity: Minor
Found in public/main/inc/lib/array.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

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

                if (isset($item[$id]) && strip_tags($item[$id]) > strip_tags($array[$lowest_id][$id])) {

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

                    $lowest_id = $index;

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

    return $temp_array;

Consider putting global function "utf8_sort" in a static class
Open

function utf8_sort($array)

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

    $locale_list = [$code.'.utf8', 'en.utf8', 'en_US.utf8', 'en_GB.utf8'];

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

            $try_sort = true;

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

        $lowest_id = 0;

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

        $temp_array[] = $array[$lowest_id];

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

        $my_local = setlocale(LC_COLLATE, $locale);

Consider putting global function "array_unique_dimensional" in a static class
Open

function array_unique_dimensional($array)

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

    $old_locale = setlocale(LC_ALL, 0);

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

    setlocale(LC_COLLATE, $old_locale);

Missing parameter name
Open

 * @param $array

Missing parameter name
Open

 * @param    array    unsorted multidimensional array

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

                if (strip_tags($item[$id]) < strip_tags($array[$lowest_id][$id])) {

Consider putting global function "array_flatten" in a static class
Open

function array_flatten(array $array)

Consider putting global function "msort" in a static class
Open

function msort($array, $id = 'id', $order = 'desc')

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

        $temp_array[] = $array[$lowest_id];

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

    if ($try_sort) {

Consider putting global function "array_to_string" in a static class
Open

function array_to_string($array, $separator = ',')

Missing parameter name
Open

 * @param $array

Missing parameter name
Open

 * @param    string    key to be sorted

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

            array_slice($array, 0, $lowest_id),

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

    $try_sort = false;

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

        if ($my_local) {

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

    foreach ($locale_list as $locale) {

Consider putting global function "shuffle_assoc" in a static class
Open

function shuffle_assoc(&$array)

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

            array_slice($array, $lowest_id + 1)

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

    $temp_array = [];

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

                    $lowest_id = $index;

The variable $lowest_id is not named in camelCase.
Open

function msort($array, $id = 'id', $order = 'desc')
{
    if (empty($array)) {
        return $array;
    }
Severity: Minor
Found in public/main/inc/lib/array.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 $try_sort is not named in camelCase.
Open

function utf8_sort($array)
{
    $old_locale = setlocale(LC_ALL, 0);
    $code = api_get_language_isocode();
    $locale_list = [$code.'.utf8', 'en.utf8', 'en_US.utf8', 'en_GB.utf8'];
Severity: Minor
Found in public/main/inc/lib/array.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 $temp_array is not named in camelCase.
Open

function msort($array, $id = 'id', $order = 'desc')
{
    if (empty($array)) {
        return $array;
    }
Severity: Minor
Found in public/main/inc/lib/array.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 $locale_list is not named in camelCase.
Open

function utf8_sort($array)
{
    $old_locale = setlocale(LC_ALL, 0);
    $code = api_get_language_isocode();
    $locale_list = [$code.'.utf8', 'en.utf8', 'en_US.utf8', 'en_GB.utf8'];
Severity: Minor
Found in public/main/inc/lib/array.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 $my_local is not named in camelCase.
Open

function utf8_sort($array)
{
    $old_locale = setlocale(LC_ALL, 0);
    $code = api_get_language_isocode();
    $locale_list = [$code.'.utf8', 'en.utf8', 'en_US.utf8', 'en_GB.utf8'];
Severity: Minor
Found in public/main/inc/lib/array.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 $old_locale is not named in camelCase.
Open

function utf8_sort($array)
{
    $old_locale = setlocale(LC_ALL, 0);
    $code = api_get_language_isocode();
    $locale_list = [$code.'.utf8', 'en.utf8', 'en_US.utf8', 'en_GB.utf8'];
Severity: Minor
Found in public/main/inc/lib/array.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 $temp_array is not named in camelCase.
Open

function msort($array, $id = 'id', $order = 'desc')
{
    if (empty($array)) {
        return $array;
    }
Severity: Minor
Found in public/main/inc/lib/array.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 $lowest_id is not named in camelCase.
Open

function msort($array, $id = 'id', $order = 'desc')
{
    if (empty($array)) {
        return $array;
    }
Severity: Minor
Found in public/main/inc/lib/array.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 $try_sort is not named in camelCase.
Open

function utf8_sort($array)
{
    $old_locale = setlocale(LC_ALL, 0);
    $code = api_get_language_isocode();
    $locale_list = [$code.'.utf8', 'en.utf8', 'en_US.utf8', 'en_GB.utf8'];
Severity: Minor
Found in public/main/inc/lib/array.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 $lowest_id is not named in camelCase.
Open

function msort($array, $id = 'id', $order = 'desc')
{
    if (empty($array)) {
        return $array;
    }
Severity: Minor
Found in public/main/inc/lib/array.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 $lowest_id is not named in camelCase.
Open

function msort($array, $id = 'id', $order = 'desc')
{
    if (empty($array)) {
        return $array;
    }
Severity: Minor
Found in public/main/inc/lib/array.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 $try_sort is not named in camelCase.
Open

function utf8_sort($array)
{
    $old_locale = setlocale(LC_ALL, 0);
    $code = api_get_language_isocode();
    $locale_list = [$code.'.utf8', 'en.utf8', 'en_US.utf8', 'en_GB.utf8'];
Severity: Minor
Found in public/main/inc/lib/array.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 $lowest_id is not named in camelCase.
Open

function msort($array, $id = 'id', $order = 'desc')
{
    if (empty($array)) {
        return $array;
    }
Severity: Minor
Found in public/main/inc/lib/array.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 $temp_array is not named in camelCase.
Open

function msort($array, $id = 'id', $order = 'desc')
{
    if (empty($array)) {
        return $array;
    }
Severity: Minor
Found in public/main/inc/lib/array.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 $lowest_id is not named in camelCase.
Open

function msort($array, $id = 'id', $order = 'desc')
{
    if (empty($array)) {
        return $array;
    }
Severity: Minor
Found in public/main/inc/lib/array.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 $lowest_id is not named in camelCase.
Open

function msort($array, $id = 'id', $order = 'desc')
{
    if (empty($array)) {
        return $array;
    }
Severity: Minor
Found in public/main/inc/lib/array.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 $my_local is not named in camelCase.
Open

function utf8_sort($array)
{
    $old_locale = setlocale(LC_ALL, 0);
    $code = api_get_language_isocode();
    $locale_list = [$code.'.utf8', 'en.utf8', 'en_US.utf8', 'en_GB.utf8'];
Severity: Minor
Found in public/main/inc/lib/array.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 $locale_list is not named in camelCase.
Open

function utf8_sort($array)
{
    $old_locale = setlocale(LC_ALL, 0);
    $code = api_get_language_isocode();
    $locale_list = [$code.'.utf8', 'en.utf8', 'en_US.utf8', 'en_GB.utf8'];
Severity: Minor
Found in public/main/inc/lib/array.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 $old_locale is not named in camelCase.
Open

function utf8_sort($array)
{
    $old_locale = setlocale(LC_ALL, 0);
    $code = api_get_language_isocode();
    $locale_list = [$code.'.utf8', 'en.utf8', 'en_US.utf8', 'en_GB.utf8'];
Severity: Minor
Found in public/main/inc/lib/array.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 $lowest_id is not named in camelCase.
Open

function msort($array, $id = 'id', $order = 'desc')
{
    if (empty($array)) {
        return $array;
    }
Severity: Minor
Found in public/main/inc/lib/array.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

There are no issues that match your filters.

Category
Status