YetiForceCompany/YetiForceCRM

View on GitHub
modules/Settings/CurrencyUpdate/crons/CurrencyUpdate.php

Summary

Maintainability
A
0 mins
Test Coverage
F
53%

Avoid using static access to class '\App\Log' in method 'process'.
Open

                \App\Log::trace('Successfully fetched new currency exchange rates for date: ' . $lastWorkingDay . ' from bank: ' . $moduleModel->getActiveBankName());

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

Avoid using static access to class '\App\Log' in method 'process'.
Open

            \App\Log::warning('Update of system currency rates ignored, no active bankin settings.');

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

Avoid using static access to class '\App\Log' in method 'process'.
Open

        \App\Log::trace('End CRON:' . __FILE__);

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

Avoid using static access to class '\App\Log' in method 'process'.
Open

                \App\Log::warning('Failed to fetch new currency exchange rates for date: ' . $lastWorkingDay . ' from bank: ' . $moduleModel->getActiveBankName());

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

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

            } else {
                \App\Log::warning('Failed to fetch new currency exchange rates for date: ' . $lastWorkingDay . ' from bank: ' . $moduleModel->getActiveBankName());
            }

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 using static access to class 'vtlib\Functions' in method 'process'.
Open

            $lastWorkingDay = vtlib\Functions::getLastWorkingDay($yesterday);

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

Avoid using static access to class '\App\Log' in method 'process'.
Open

        \App\Log::trace('Start CRON:' . __FILE__);

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

Avoid using static access to class 'Settings_CurrencyUpdate_Module_Model' in method 'process'.
Open

        $moduleModel = Settings_CurrencyUpdate_Module_Model::getCleanInstance();

StaticAccess

Since: 1.4.0

Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

Example

class Foo
{
    public function bar()
    {
        Bar::baz();
    }
}

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

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

        } else {
            \App\Log::warning('Update of system currency rates ignored, no active bankin settings.');
        }

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

Call to method trace from undeclared class \App\Log
Open

        \App\Log::trace('End CRON:' . __FILE__);

Call to method trace from undeclared class \App\Log
Open

                \App\Log::trace('Successfully fetched new currency exchange rates for date: ' . $lastWorkingDay . ' from bank: ' . $moduleModel->getActiveBankName());

Call to method warning from undeclared class \App\Log
Open

                \App\Log::warning('Failed to fetch new currency exchange rates for date: ' . $lastWorkingDay . ' from bank: ' . $moduleModel->getActiveBankName());

Call to method trace from undeclared class \App\Log
Open

        \App\Log::trace('Start CRON:' . __FILE__);

Call to method warning from undeclared class \App\Log
Open

            \App\Log::warning('Update of system currency rates ignored, no active bankin settings.');

Avoid excessively long class names like Settings_CurrencyUpdate_CurrencyUpdate_Cron. Keep class name length under 40.
Open

class Settings_CurrencyUpdate_CurrencyUpdate_Cron extends \App\CronHandler
{
    /** {@inheritdoc} */
    public function process()
    {

LongClassName

Since: 2.9

Detects when classes or interfaces are declared with excessively long names.

Example

class ATooLongClassNameThatHintsAtADesignProblem {

}

interface ATooLongInterfaceNameThatHintsAtADesignProblem {

}

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

Each class must be in a namespace of at least one level (a top-level vendor name)
Open

class Settings_CurrencyUpdate_CurrencyUpdate_Cron extends \App\CronHandler

The class Settings_CurrencyUpdate_CurrencyUpdate_Cron is not named in CamelCase.
Open

class Settings_CurrencyUpdate_CurrencyUpdate_Cron extends \App\CronHandler
{
    /** {@inheritdoc} */
    public function process()
    {

CamelCaseClassName

Since: 0.2

It is considered best practice to use the CamelCase notation to name classes.

Example

class class_name {
}

Source

Line exceeds 120 characters; contains 163 characters
Open

                \App\Log::warning('Failed to fetch new currency exchange rates for date: ' . $lastWorkingDay . ' from bank: ' . $moduleModel->getActiveBankName());

Spaces must be used to indent lines; tabs are not allowed
Open

        $activeBankId = $moduleModel->getActiveBankId();

Spaces must be used to indent lines; tabs are not allowed
Open

                \App\Log::warning('Failed to fetch new currency exchange rates for date: ' . $lastWorkingDay . ' from bank: ' . $moduleModel->getActiveBankName());

Spaces must be used to indent lines; tabs are not allowed
Open

    }

Spaces must be used to indent lines; tabs are not allowed
Open

    /** {@inheritdoc} */

Spaces must be used to indent lines; tabs are not allowed
Open

        if (!empty($activeBankId)) {

Spaces must be used to indent lines; tabs are not allowed
Open

        } else {

Spaces must be used to indent lines; tabs are not allowed
Open

            $yesterday = date('Y-m-d', strtotime('-1 day'));

Spaces must be used to indent lines; tabs are not allowed
Open

                \App\Log::trace('Successfully fetched new currency exchange rates for date: ' . $lastWorkingDay . ' from bank: ' . $moduleModel->getActiveBankName());

Spaces must be used to indent lines; tabs are not allowed
Open

            \App\Log::warning('Update of system currency rates ignored, no active bankin settings.');

Spaces must be used to indent lines; tabs are not allowed
Open

        }

Spaces must be used to indent lines; tabs are not allowed
Open

        \App\Log::trace('Start CRON:' . __FILE__);

Spaces must be used to indent lines; tabs are not allowed
Open

        $moduleModel = Settings_CurrencyUpdate_Module_Model::getCleanInstance();

Spaces must be used to indent lines; tabs are not allowed
Open

        \App\Log::trace('End CRON:' . __FILE__);

Spaces must be used to indent lines; tabs are not allowed
Open

    public function process()

Spaces must be used to indent lines; tabs are not allowed
Open

            }

Spaces must be used to indent lines; tabs are not allowed
Open

            $status = $moduleModel->fetchCurrencyRates($lastWorkingDay, true);

Spaces must be used to indent lines; tabs are not allowed
Open

            if ($status) {

Line exceeds 120 characters; contains 166 characters
Open

                \App\Log::trace('Successfully fetched new currency exchange rates for date: ' . $lastWorkingDay . ' from bank: ' . $moduleModel->getActiveBankName());

Spaces must be used to indent lines; tabs are not allowed
Open

    {

Spaces must be used to indent lines; tabs are not allowed
Open

            $lastWorkingDay = vtlib\Functions::getLastWorkingDay($yesterday);

Spaces must be used to indent lines; tabs are not allowed
Open

            } else {

Class name "Settings_CurrencyUpdate_CurrencyUpdate_Cron" is not in camel caps format
Open

class Settings_CurrencyUpdate_CurrencyUpdate_Cron extends \App\CronHandler

There are no issues that match your filters.

Category
Status