chamilo/chamilo-lms

View on GitHub
public/plugin/advanced_subscription/src/HookAdvancedSubscription.php

Summary

Maintainability
A
0 mins
Test Coverage

The method HookAdvancedSubscription::WSListSessionsDetailsByCategory() calls the typical debug function print_r() which is mostly only used during development.
Open

            error_log('Params '.print_r($params, 1));

DevelopmentCodeFragment

Since: 2.3.0

Functions like vardump(), printr() etc. are normally only used during development and therefore such calls in production code are a good indicator that they were just forgotten.

Example

class SuspectCode {

    public function doSomething(array $items)
    {
        foreach ($items as $i => $item) {
            // …

            if ('qafoo' == $item) var_dump($i);

            // …
        }
    }
}

Source https://phpmd.org/rules/design.html#developmentcodefragment

The method HookAdvancedSubscription::WSSessionGetDetailsByUser() calls the typical debug function print_r() which is mostly only used during development.
Open

            error_log('Params '.print_r($params, 1));

DevelopmentCodeFragment

Since: 2.3.0

Functions like vardump(), printr() etc. are normally only used during development and therefore such calls in production code are a good indicator that they were just forgotten.

Example

class SuspectCode {

    public function doSomething(array $items)
    {
        foreach ($items as $i => $item) {
            // …

            if ('qafoo' == $item) var_dump($i);

            // …
        }
    }
}

Source https://phpmd.org/rules/design.html#developmentcodefragment

The method HookAdvancedSubscription::WSSessionListInCategory() calls the typical debug function print_r() which is mostly only used during development.
Open

            error_log('Params '.print_r($params, 1));

DevelopmentCodeFragment

Since: 2.3.0

Functions like vardump(), printr() etc. are normally only used during development and therefore such calls in production code are a good indicator that they were just forgotten.

Example

class SuspectCode {

    public function doSomething(array $items)
    {
        foreach ($items as $i => $item) {
            // …

            if ('qafoo' == $item) var_dump($i);

            // …
        }
    }
}

Source https://phpmd.org/rules/design.html#developmentcodefragment

Missing class import via use statement (line '450', column '24').
Open

        $datePub = new DateTime();

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

                        } else {
                            try {
                                $isAllowed = self::$plugin->isAllowedToDoRequest($userId, $params);
                                $data['message'] = self::$plugin->getStatusMessage($status, $isAllowed);
                            } catch (\Exception $e) {

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

            } else {
                // Return soap fault No result was found
                $result = return_error(WS_ERROR_NOT_FOUND_RESULT);
            }

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

        } else {
            // Return soap fault Not valid input params

            return return_error(WS_ERROR_INVALID_INPUT);
        }

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

                    } else {
                        if (!$isUserInTargetGroup) {
                            $data['status'] = -2;
                        } else {
                            try {

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

                } else {
                    // Return soap fault No result was found
                    $result = return_error(WS_ERROR_NOT_FOUND_RESULT);
                }

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

                            } else {
                                if (ADVANCED_SUBSCRIPTION_QUEUE_STATUS_ADMIN_APPROVED == $status) {
                                    $data['action_url'] = self::$plugin->getSessionUrl($sessionId);
                                } elseif (ADVANCED_SUBSCRIPTION_QUEUE_STATUS_NO_QUEUE == $status) {
                                    // in Queue or not, cannot be subscribed to session

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

        } else {
            // Return soap fault Not valid input params

            return return_error(WS_ERROR_INVALID_INPUT);
        }

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

        } else {
            // Return soap fault Not valid input params
            $result = return_error(WS_ERROR_INVALID_INPUT);
        }

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

Missing parameter name
Open

     * @param $params

Missing parameter name
Open

     * @param $params

The method WSSessionListInCategory is not named in camelCase.
Open

    public static function WSSessionListInCategory($params)
    {
        global $debug;

        if ($debug) {

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

    public static function WSListSessionsDetailsByCategory($params)
    {
        global $debug;

        if ($debug) {

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

    public static function WSSessionGetDetailsByUser($params)
    {
        global $debug;

        if ($debug) {

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