YetiForceCompany/YetiForceCRM

View on GitHub
modules/Settings/CurrencyUpdate/models/Module.php

Summary

Maintainability
C
1 day
Test Coverage
D
62%

Method getCRMConversionRate has 72 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getCRMConversionRate($from, $to, $date = '')
    {
        $mainCurrencyCode = \App\Fields\Currency::getDefault()['currency_code'];
        $activeBankId = self::getActiveBankId();
        $exchange = false;
Severity: Major
Found in modules/Settings/CurrencyUpdate/models/Module.php - About 2 hrs to fix

    Function getCRMConversionRate has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getCRMConversionRate($from, $to, $date = '')
        {
            $mainCurrencyCode = \App\Fields\Currency::getDefault()['currency_code'];
            $activeBankId = self::getActiveBankId();
            $exchange = false;
    Severity: Minor
    Found in modules/Settings/CurrencyUpdate/models/Module.php - About 2 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    File Module.php has 262 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    /**
     * @copyright YetiForce S.A.
     * @license   YetiForce Public License 6.5 (licenses/LicenseEN.txt or yetiforce.com)
    Severity: Minor
    Found in modules/Settings/CurrencyUpdate/models/Module.php - About 2 hrs to fix

      Function refreshBanks has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          public function refreshBanks()
          {
              $db = App\Db::getInstance();
              $dataReader = (new \App\Db\Query())->select(['id', 'bank_name'])
                  ->from('yetiforce_currencyupdate_banks')
      Severity: Minor
      Found in modules/Settings/CurrencyUpdate/models/Module.php - About 1 hr to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Method fetchCurrencyRates has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function fetchCurrencyRates($dateCur, $cron = false)
          {
              if (!\App\RequestUtil::isNetConnection()) {
                  return false;
              }
      Severity: Minor
      Found in modules/Settings/CurrencyUpdate/models/Module.php - About 1 hr to fix

        Function fetchCurrencyRates has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            public function fetchCurrencyRates($dateCur, $cron = false)
            {
                if (!\App\RequestUtil::isNetConnection()) {
                    return false;
                }
        Severity: Minor
        Found in modules/Settings/CurrencyUpdate/models/Module.php - About 35 mins to fix

        Cognitive Complexity

        Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

        A method's cognitive complexity is based on a few simple rules:

        • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
        • Code is considered more complex for each "break in the linear flow of the code"
        • Code is considered more complex when "flow breaking structures are nested"

        Further reading

        The method getCRMConversionRate() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10.
        Open

            public function getCRMConversionRate($from, $to, $date = '')
            {
                $mainCurrencyCode = \App\Fields\Currency::getDefault()['currency_code'];
                $activeBankId = self::getActiveBankId();
                $exchange = false;

        CyclomaticComplexity

        Since: 0.1

        Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

        Example

        // Cyclomatic Complexity = 11
        class Foo {
        1   public function example() {
        2       if ($a == $b) {
        3           if ($a1 == $b1) {
                        fiddle();
        4           } elseif ($a2 == $b2) {
                        fiddle();
                    } else {
                        fiddle();
                    }
        5       } elseif ($c == $d) {
        6           while ($c == $d) {
                        fiddle();
                    }
        7        } elseif ($e == $f) {
        8           for ($n = 0; $n < $h; $n++) {
                        fiddle();
                    }
                } else {
                    switch ($z) {
        9               case 1:
                            fiddle();
                            break;
        10              case 2:
                            fiddle();
                            break;
        11              case 3:
                            fiddle();
                            break;
                        default:
                            fiddle();
                            break;
                    }
                }
            }
        }

        Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

        Refactor this function to reduce its Cognitive Complexity from 23 to the 15 allowed.
        Open

            public function getCRMConversionRate($from, $to, $date = '')

        Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

        See

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

                return array_diff($unsupported, $supported);

        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

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

                    $unsupported[$name] = $code;

        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 '111', column '21').
        Open

                    $isExists = (new \App\Db\Query())->from('yetiforce_currencyupdate_banks')->where(['bank_name' => $bankClassName])->exists();

        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 '334', column '18').
        Open

                        $query = new App\Db\Query();

        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 '15').
        Open

                return (new \App\Db\Query())->select(['bank_name'])->from('yetiforce_currencyupdate_banks')->where(['active' => 1])->scalar();

        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 '295', column '18').
        Open

                        $query = new App\Db\Query();

        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 fetchCurrencyRates has a boolean flag argument $cron, which is a certain sign of a Single Responsibility Principle violation.
        Open

            public function fetchCurrencyRates($dateCur, $cron = false)

        BooleanArgumentFlag

        Since: 1.4.0

        A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

        Example

        class Foo {
            public function bar($flag = true) {
            }
        }

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

        Missing class import via use statement (line '306', column '18').
        Open

                        $query = new App\Db\Query();

        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 '319', column '17').
        Open

                    $query = new App\Db\Query();

        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 '237', column '22').
        Open

                $dataReader = (new \App\Db\Query())->select(['currency_name', 'currency_code'])

        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 '106', column '16').
        Open

                foreach (new DirectoryIterator(ROOT_DIRECTORY . '/modules/Settings/CurrencyUpdate/bankmodels/') as $fileInfo) {

        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 '28', column '15').
        Open

                return (new \App\Db\Query())

        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 '60', column '22').
        Open

                $dataReader = (new \App\Db\Query())->select(['id', 'currency_code'])

        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 '77', column '20').
        Open

                    $currNum = (new \App\Db\Query())->from('yetiforce_currencyupdate')

        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 '164', column '15').
        Open

                return (new \App\Db\Query())->select(['id'])

        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 '287', column '17').
        Open

                    $query = new App\Db\Query();

        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 '95', column '22').
        Open

                $dataReader = (new \App\Db\Query())->select(['id', 'bank_name'])

        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 '181', column '17').
        Open

                $query = (new App\Db\Query())->select(['exchange', 'currency_name', 'currency_code', 'currency_symbol', 'fetch_date', 'exchange_date'])

        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 '375', column '15').
        Open

                return (new \App\Db\Query())->select(['id'])->from('yetiforce_currencyupdate_banks')->where(['active' => 1])->scalar();

        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 convertFromTo has a boolean flag argument $date, which is a certain sign of a Single Responsibility Principle violation.
        Open

            public function convertFromTo($amount, $from, $to, $date = false)

        BooleanArgumentFlag

        Since: 1.4.0

        A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

        Example

        class Foo {
            public function bar($flag = true) {
            }
        }

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

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

                        } else {
                            $exchange = $fromExchange * $convertToMainCurrency;
                        }

        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 '\App\Fields\Currency' in method 'getCRMConversionRate'.
        Open

        }

        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\RequestUtil' in method 'fetchCurrencyRates'.
        Open

                if (!\App\RequestUtil::isNetConnection()) {

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

                } else {
                    $query->andWhere(['exchange_date' => $dateCur]);
                }

        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 '\App\Fields\Currency' in method 'getCRMConversionRate'.
        Open

        }

        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\Db' in method 'refreshBanks'.
        Open

                $db = App\Db::getInstance();

        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\RequestUtil' in method 'getSupportedCurrencies'.
        Open

                if (!\App\RequestUtil::isNetConnection()) {

        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\RequestUtil' in method 'getUnSupportedCurrencies'.
        Open

                if (!\App\RequestUtil::isNetConnection()) {

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

                else {
                    if (\App\RequestUtil::isNetConnection()) {
                        $query = new App\Db\Query();
                        $query->from('yetiforce_currencyupdate')
                            ->innerJoin('vtiger_currency_info', 'vtiger_currency_info.id = yetiforce_currencyupdate.currency_id AND deleted = :del', [':del' => 0])

        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 '\App\Db' in method 'setActiveBankById'.
        Open

                $db = \App\Db::getInstance();

        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 'getSupportedCurrencies'.
        Open

                    \App\Log::error('Error during downloading table: ' . PHP_EOL . $ex->__toString() . PHP_EOL, 'CurrencyUpdate');

        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\Fields\Currency' in method 'getCRMConversionRate'.
        Open

        }

        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\RequestUtil' in method 'getCRMConversionRate'.
        Open

                    if (\App\RequestUtil::isNetConnection()) {

        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\Fields\Currency' in method 'getCurrencyNum'.
        Open

                return \count(\App\Fields\Currency::getAll(true));

        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

        Define a constant instead of duplicating this literal "active" 6 times.
        Open

                        $db->createCommand()->insert('yetiforce_currencyupdate_banks', ['bank_name' => $bankClassName, 'active' => 0])->execute();

        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

        Noncompliant Code Example

        With the default threshold of 3:

        function run() {
          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
          execute('action1');
          release('action1');
        }
        

        Compliant Solution

        ACTION_1 = 'action1';
        
        function run() {
          prepare(ACTION_1);
          execute(ACTION_1);
          release(ACTION_1);
        }
        

        Exceptions

        To prevent generating some false-positives, literals having less than 5 characters are excluded.

        Define a constant instead of duplicating this literal "conversion_rate" 3 times.
        Open

                    ->update('vtiger_currency_info', ['conversion_rate' => $rate], ['currency_code' => $currency])

        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

        Noncompliant Code Example

        With the default threshold of 3:

        function run() {
          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
          execute('action1');
          release('action1');
        }
        

        Compliant Solution

        ACTION_1 = 'action1';
        
        function run() {
          prepare(ACTION_1);
          execute(ACTION_1);
          release(ACTION_1);
        }
        

        Exceptions

        To prevent generating some false-positives, literals having less than 5 characters are excluded.

        Define a constant instead of duplicating this literal "_BankModel" 3 times.
        Open

                    $activeBankName = 'Settings_CurrencyUpdate_' . $this->getActiveBankName() . '_BankModel';

        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

        Noncompliant Code Example

        With the default threshold of 3:

        function run() {
          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
          execute('action1');
          release('action1');
        }
        

        Compliant Solution

        ACTION_1 = 'action1';
        
        function run() {
          prepare(ACTION_1);
          execute(ACTION_1);
          release(ACTION_1);
        }
        

        Exceptions

        To prevent generating some false-positives, literals having less than 5 characters are excluded.

        Define a constant instead of duplicating this literal "vtiger_currency_info.id = yetiforce_currencyupdate.currency_id AND deleted = :del" 3 times.
        Open

                            ->innerJoin('vtiger_currency_info', 'vtiger_currency_info.id = yetiforce_currencyupdate.currency_id AND deleted = :del', [':del' => 0])

        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

        Noncompliant Code Example

        With the default threshold of 3:

        function run() {
          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
          execute('action1');
          release('action1');
        }
        

        Compliant Solution

        ACTION_1 = 'action1';
        
        function run() {
          prepare(ACTION_1);
          execute(ACTION_1);
          release(ACTION_1);
        }
        

        Exceptions

        To prevent generating some false-positives, literals having less than 5 characters are excluded.

        Define a constant instead of duplicating this literal "currency_name" 4 times.
        Open

                    ->select(['currency_name'])

        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

        Noncompliant Code Example

        With the default threshold of 3:

        function run() {
          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
          execute('action1');
          release('action1');
        }
        

        Compliant Solution

        ACTION_1 = 'action1';
        
        function run() {
          prepare(ACTION_1);
          execute(ACTION_1);
          release(ACTION_1);
        }
        

        Exceptions

        To prevent generating some false-positives, literals having less than 5 characters are excluded.

        Define a constant instead of duplicating this literal "currency_code" 13 times.
        Open

                    ->where(['currency_code' => $code])

        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

        Noncompliant Code Example

        With the default threshold of 3:

        function run() {
          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
          execute('action1');
          release('action1');
        }
        

        Compliant Solution

        ACTION_1 = 'action1';
        
        function run() {
          prepare(ACTION_1);
          execute(ACTION_1);
          release(ACTION_1);
        }
        

        Exceptions

        To prevent generating some false-positives, literals having less than 5 characters are excluded.

        Define a constant instead of duplicating this literal "yetiforce_currencyupdate.exchange_date" 3 times.
        Open

                            ->where(['yetiforce_currencyupdate.exchange_date' => $date,

        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

        Noncompliant Code Example

        With the default threshold of 3:

        function run() {
          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
          execute('action1');
          release('action1');
        }
        

        Compliant Solution

        ACTION_1 = 'action1';
        
        function run() {
          prepare(ACTION_1);
          execute(ACTION_1);
          release(ACTION_1);
        }
        

        Exceptions

        To prevent generating some false-positives, literals having less than 5 characters are excluded.

        Define a constant instead of duplicating this literal "bank_name" 6 times.
        Open

                $dataReader = (new \App\Db\Query())->select(['id', 'bank_name'])

        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

        Noncompliant Code Example

        With the default threshold of 3:

        function run() {
          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
          execute('action1');
          release('action1');
        }
        

        Compliant Solution

        ACTION_1 = 'action1';
        
        function run() {
          prepare(ACTION_1);
          execute(ACTION_1);
          release(ACTION_1);
        }
        

        Exceptions

        To prevent generating some false-positives, literals having less than 5 characters are excluded.

        Define a constant instead of duplicating this literal "yetiforce_currencyupdate" 8 times.
        Open

                    $currNum = (new \App\Db\Query())->from('yetiforce_currencyupdate')

        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

        Noncompliant Code Example

        With the default threshold of 3:

        function run() {
          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
          execute('action1');
          release('action1');
        }
        

        Compliant Solution

        ACTION_1 = 'action1';
        
        function run() {
          prepare(ACTION_1);
          execute(ACTION_1);
          release(ACTION_1);
        }
        

        Exceptions

        To prevent generating some false-positives, literals having less than 5 characters are excluded.

        Define a constant instead of duplicating this literal "Settings_CurrencyUpdate_" 3 times.
        Open

                    $activeBankName = 'Settings_CurrencyUpdate_' . $this->getActiveBankName() . '_BankModel';

        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

        Noncompliant Code Example

        With the default threshold of 3:

        function run() {
          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
          execute('action1');
          release('action1');
        }
        

        Compliant Solution

        ACTION_1 = 'action1';
        
        function run() {
          prepare(ACTION_1);
          execute(ACTION_1);
          release(ACTION_1);
        }
        

        Exceptions

        To prevent generating some false-positives, literals having less than 5 characters are excluded.

        Define a constant instead of duplicating this literal "exchange_date" 7 times.
        Open

                        ->where(['exchange_date' => $dateCur, 'currency_id' => $currIds, 'bank_id' => $selectBankId])

        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

        Noncompliant Code Example

        With the default threshold of 3:

        function run() {
          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
          execute('action1');
          release('action1');
        }
        

        Compliant Solution

        ACTION_1 = 'action1';
        
        function run() {
          prepare(ACTION_1);
          execute(ACTION_1);
          release(ACTION_1);
        }
        

        Exceptions

        To prevent generating some false-positives, literals having less than 5 characters are excluded.

        Define a constant instead of duplicating this literal "yetiforce_currencyupdate.bank_id" 4 times.
        Open

                    ->where(['yetiforce_currencyupdate.bank_id' => $bankId]);

        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

        Noncompliant Code Example

        With the default threshold of 3:

        function run() {
          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
          execute('action1');
          release('action1');
        }
        

        Compliant Solution

        ACTION_1 = 'action1';
        
        function run() {
          prepare(ACTION_1);
          execute(ACTION_1);
          release(ACTION_1);
        }
        

        Exceptions

        To prevent generating some false-positives, literals having less than 5 characters are excluded.

        Define a constant instead of duplicating this literal "yetiforce_currencyupdate_banks" 10 times.
        Open

                    ->from('yetiforce_currencyupdate_banks')

        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

        Noncompliant Code Example

        With the default threshold of 3:

        function run() {
          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
          execute('action1');
          release('action1');
        }
        

        Compliant Solution

        ACTION_1 = 'action1';
        
        function run() {
          prepare(ACTION_1);
          execute(ACTION_1);
          release(ACTION_1);
        }
        

        Exceptions

        To prevent generating some false-positives, literals having less than 5 characters are excluded.

        Define a constant instead of duplicating this literal "bank_id" 3 times.
        Open

                        ->where(['exchange_date' => $dateCur, 'currency_id' => $currIds, 'bank_id' => $selectBankId])

        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

        Noncompliant Code Example

        With the default threshold of 3:

        function run() {
          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
          execute('action1');
          release('action1');
        }
        

        Compliant Solution

        ACTION_1 = 'action1';
        
        function run() {
          prepare(ACTION_1);
          execute(ACTION_1);
          release(ACTION_1);
        }
        

        Exceptions

        To prevent generating some false-positives, literals having less than 5 characters are excluded.

        Define a constant instead of duplicating this literal "currency_id" 3 times.
        Open

                        ->where(['exchange_date' => $dateCur, 'currency_id' => $currIds, 'bank_id' => $selectBankId])

        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

        Noncompliant Code Example

        With the default threshold of 3:

        function run() {
          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
          execute('action1');
          release('action1');
        }
        

        Compliant Solution

        ACTION_1 = 'action1';
        
        function run() {
          prepare(ACTION_1);
          execute(ACTION_1);
          release(ACTION_1);
        }
        

        Exceptions

        To prevent generating some false-positives, literals having less than 5 characters are excluded.

        Define a constant instead of duplicating this literal "vtiger_currency_info.currency_code" 3 times.
        Open

                                'vtiger_currency_info.currency_code' => $to, ])

        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

        Noncompliant Code Example

        With the default threshold of 3:

        function run() {
          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
          execute('action1');
          release('action1');
        }
        

        Compliant Solution

        ACTION_1 = 'action1';
        
        function run() {
          prepare(ACTION_1);
          execute(ACTION_1);
          release(ACTION_1);
        }
        

        Exceptions

        To prevent generating some false-positives, literals having less than 5 characters are excluded.

        Define a constant instead of duplicating this literal "vtiger_currency_info" 9 times.
        Open

                    ->from('vtiger_currency_info')

        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

        Noncompliant Code Example

        With the default threshold of 3:

        function run() {
          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
          execute('action1');
          release('action1');
        }
        

        Compliant Solution

        ACTION_1 = 'action1';
        
        function run() {
          prepare(ACTION_1);
          execute(ACTION_1);
          release(ACTION_1);
        }
        

        Exceptions

        To prevent generating some false-positives, literals having less than 5 characters are excluded.

        Define a constant instead of duplicating this literal "exchange" 3 times.
        Open

                    ->update('yetiforce_currencyupdate', ['exchange' => $exchange], ['id' => $id])

        Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

        On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

        Noncompliant Code Example

        With the default threshold of 3:

        function run() {
          prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
          execute('action1');
          release('action1');
        }
        

        Compliant Solution

        ACTION_1 = 'action1';
        
        function run() {
          prepare(ACTION_1);
          execute(ACTION_1);
          release(ACTION_1);
        }
        

        Exceptions

        To prevent generating some false-positives, literals having less than 5 characters are excluded.

        Avoid unused parameters such as '$cron'.
        Open

            public function fetchCurrencyRates($dateCur, $cron = false)

        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

        Call to undeclared method \App\Db\Query::from
        Open

                    $isExists = (new \App\Db\Query())->from('yetiforce_currencyupdate_banks')->where(['bank_name' => $bankClassName])->exists();

        Call to undeclared method \App\Db::createCommand
        Open

                    $db->createCommand()->update('yetiforce_currencyupdate_banks', ['active' => 1], ['bank_name' => 'NBP'])->execute();

        Saw unextractable annotation for comment '* @return <array> - array of supported currencies'</array>
        Open

             * @return <Array> - array of supported currencies

        Saw unextractable annotation for comment '* @return <array> - array of unsupported currencies'</array>
        Open

             * @return <Array> - array of unsupported currencies

        Call to undeclared method \App\Db\Query::from
        Open

                    $currNum = (new \App\Db\Query())->from('yetiforce_currencyupdate')

        Saw unextractable annotation for comment '* @param <float> $exchange - exchange rate'</float>
        Open

             * @param <Float>   $exchange - exchange rate

        Saw unextractable annotation for comment '* @param <float> $exchange - exchange rate'</float>
        Open

             * @param <Float>   $exchange     - exchange rate

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

                    \App\Log::error('Error during downloading table: ' . PHP_EOL . $ex->__toString() . PHP_EOL, 'CurrencyUpdate');

        Call to undeclared method \App\Db::createCommand
        Open

                $db->createCommand()->update('yetiforce_currencyupdate_banks', ['active' => 0])->execute();

        Call to undeclared method \App\Db\Query::select
        Open

                return (new \App\Db\Query())

        Expected @param annotation for dateCur to be before the @param annotation for cron
        Open

             * @param bool   $cron    - true if fired by server, and so updates systems currency conversion rates

        Saw unextractable annotation for comment '* @param <integer> $currId - currency id'</integer>
        Open

             * @param <Integer> $currId       - currency id

        Saw unextractable annotation for comment '* @param <integer> $bankId - id of bank'</integer>
        Open

             * @param <Integer> $bankId       - id of bank

        Variable $unsupported was undeclared, but array fields are being added to it.
        Open

                    $unsupported[$name] = $code;

        Saw unextractable annotation for comment '* @param <integer> $bankId - bank id'</integer>
        Open

             * @param <Integer> $bankId - bank id

        Saw unextractable annotation for comment '* @param <integer> $currencyId - systems currency id'</integer>
        Open

             * @param <Integer> $currencyId   - systems currency id

        Saw unextractable annotation for comment '* @param <date> $date - date for which to fetch exchange rates'</date>
        Open

             * @param <Date> $date    - date for which to fetch exchange rates

        Call to undeclared method \App\Db::createCommand
        Open

                \App\Db::getInstance()->createCommand()->insert('yetiforce_currencyupdate', [

        Call to undeclared method \App\Db\Query::select
        Open

                return (new \App\Db\Query())->select(['bank_name'])->from('yetiforce_currencyupdate_banks')->where(['active' => 1])->scalar();

        Saw unextractable annotation for comment '* @param <date> $exchangeDate - date of exchange rate'</date>
        Open

             * @param <Date>    $exchangeDate - date of exchange rate

        Call to undeclared method \App\Db\Query::select
        Open

                return (new \App\Db\Query())->select(['id'])->from('yetiforce_currencyupdate_banks')->where(['active' => 1])->scalar();

        Call to undeclared method \App\Db::createCommand
        Open

                $result = $db->createCommand()->update('yetiforce_currencyupdate_banks', ['active' => 1], ['id' => $bankId])->execute();

        Saw unextractable annotation for comment '* @param <integer> $id - exchange rate id'</integer>
        Open

             * @param <Integer> $id       - exchange rate id

        Saw unextractable annotation for comment '* @return <integer> - bank id'</integer>
        Open

             * @return <Integer> - bank id

        Call to undeclared method \App\Db\Query::select
        Open

                        $query->select(['conversion_rate'])

        Call to undeclared method \App\Db\Query::select
        Open

                    $query->select(['yetiforce_currencyupdate.exchange'])

        Saw unextractable annotation for comment '* @return <float> - floating point number'</float>
        Open

             * @return <Float> - floating point number

        Saw unextractable annotation for comment '* @return <integer> - number of currencies'</integer>
        Open

             * @return <Integer> - number of currencies

        Call to undeclared method \App\Db\Query::select
        Open

                $dataReader = (new \App\Db\Query())->select(['currency_name', 'currency_code'])

        Saw unextractable annotation for comment '* @param <float> $exchange - exchange rate'</float>
        Open

             * @param <Float> $exchange - exchange rate

        Saw unextractable annotation for comment '* @param <date> $dateCur - date, if empty show this months history'</date>
        Open

             * @param <Date>       $dateCur - date, if empty show this months history

        Saw unextractable annotation for comment '* @return <float> - conversion rate'</float>
        Open

             * @return <Float> - conversion rate

        Call to undeclared method \App\Db::createCommand
        Open

                \App\Db::getInstance()->createCommand()

        Saw unextractable annotation for comment '* @param <date> $exchangeDate - exchange date'</date>
        Open

             * @param <Date>    $exchangeDate - exchange date

        Saw unextractable annotation for comment '* @param <integer> $bankId - bank id'</integer>
        Open

             * @param <Integer>    $bankId  - bank id

        Saw unextractable annotation for comment '* @return <array> - array containing currency rates'</array>
        Open

             * @return <Array> - array containing currency rates

        Call to undeclared method \App\Db::createCommand
        Open

                \App\Db::getInstance()->createCommand()

        Saw unextractable annotation for comment '* @param <integer> $bankId - bank id'</integer>
        Open

             * @param <Integer> $bankId       - bank id

        Call to undeclared method \App\Db\Query::select
        Open

                return (new \App\Db\Query())->select(['id'])

        Call to undeclared method \App\Db\Query::count
        Open

                        $num = (float) ($query->count());

        Saw unextractable annotation for comment '* @param <date> $date - date of the exchange rate'</date>
        Open

             * @param <Date>  $date   - date of the exchange rate

        Call to undeclared method \App\Db\Query::select
        Open

                $dataReader = (new \App\Db\Query())->select(['id', 'currency_code'])

        Call to undeclared method \App\Db::createCommand
        Open

                        $db->createCommand()->delete('yetiforce_currencyupdate_banks', ['id' => $id])->execute();

        Call to undeclared method \App\Db\Query::select
        Open

                $query = (new App\Db\Query())->select(['exchange', 'currency_name', 'currency_code', 'currency_symbol', 'fetch_date', 'exchange_date'])

        Call to undeclared method \App\Db\Query::select
        Open

                        $query->select(['yetiforce_currencyupdate.exchange'])

        Call to undeclared method \App\Db::createCommand
        Open

                        $db->createCommand()->insert('yetiforce_currencyupdate_banks', ['bank_name' => $bankClassName, 'active' => 0])->execute();

        Saw unextractable annotation for comment '* @return <integer> - currency rate id'</integer>
        Open

             * @return <Integer> - currency rate id

        Saw unextractable annotation for comment '* @param <float> $amount - number to convert'</float>
        Open

             * @param <Float> $amount - number to convert

        Saw unextractable annotation for comment '* @param <date> $date - date of the exchange rate'</date>
        Open

             * @param <Date> $date - date of the exchange rate

        Call to undeclared method \App\Db\Query::select
        Open

                    $query->select(['conversion_rate'])

        Call to undeclared method \App\Db\Query::select
        Open

                $dataReader = (new \App\Db\Query())->select(['id', 'bank_name'])

        Call to undeclared method \App\Db\Query::from
        Open

                        $query->from('yetiforce_currencyupdate')

        Avoid excessively long variable names like $convertToMainCurrency. Keep variable name length under 20.
        Open

                        $convertToMainCurrency = 1 / $exchange;

        LongVariable

        Since: 0.2

        Detects when a field, formal or local variable is declared with a long name.

        Example

        class Something {
            protected $reallyLongIntName = -3; // VIOLATION - Field
            public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                $otherReallyLongName = -5; // VIOLATION - Local
                for ($interestingIntIndex = 0; // VIOLATION - For
                     $interestingIntIndex < 10;
                     $interestingIntIndex++ ) {
                }
            }
        }

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

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

        class Settings_CurrencyUpdate_Module_Model extends \App\Base

        The class Settings_CurrencyUpdate_Module_Model is not named in CamelCase.
        Open

        class Settings_CurrencyUpdate_Module_Model extends \App\Base
        {
            // Returns objects instance
        
            public static function getCleanInstance()

        CamelCaseClassName

        Since: 0.2

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

        Example

        class class_name {
        }

        Source

        Avoid variables with short names like $to. Configured minimum length is 3.
        Open

            public function getCRMConversionRate($from, $to, $date = '')

        ShortVariable

        Since: 0.2

        Detects when a field, local, or parameter has a very short name.

        Example

        class Something {
            private $q = 15; // VIOLATION - Field
            public static function main( array $as ) { // VIOLATION - Formal
                $r = 20 + $this->q; // VIOLATION - Local
                for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                    $r += $this->q;
                }
            }
        }

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

        Avoid variables with short names like $id. Configured minimum length is 3.
        Open

                    $id = $row['id'];

        ShortVariable

        Since: 0.2

        Detects when a field, local, or parameter has a very short name.

        Example

        class Something {
            private $q = 15; // VIOLATION - Field
            public static function main( array $as ) { // VIOLATION - Formal
                $r = 20 + $this->q; // VIOLATION - Local
                for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                    $r += $this->q;
                }
            }
        }

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

        Avoid variables with short names like $db. Configured minimum length is 3.
        Open

                $db = App\Db::getInstance();

        ShortVariable

        Since: 0.2

        Detects when a field, local, or parameter has a very short name.

        Example

        class Something {
            private $q = 15; // VIOLATION - Field
            public static function main( array $as ) { // VIOLATION - Formal
                $r = 20 + $this->q; // VIOLATION - Local
                for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                    $r += $this->q;
                }
            }
        }

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

        Avoid variables with short names like $id. Configured minimum length is 3.
        Open

            public function updateCurrencyRate($id, $exchange)

        ShortVariable

        Since: 0.2

        Detects when a field, local, or parameter has a very short name.

        Example

        class Something {
            private $q = 15; // VIOLATION - Field
            public static function main( array $as ) { // VIOLATION - Formal
                $r = 20 + $this->q; // VIOLATION - Local
                for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                    $r += $this->q;
                }
            }
        }

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

        Avoid variables with short names like $db. Configured minimum length is 3.
        Open

                $db = \App\Db::getInstance();

        ShortVariable

        Since: 0.2

        Detects when a field, local, or parameter has a very short name.

        Example

        class Something {
            private $q = 15; // VIOLATION - Field
            public static function main( array $as ) { // VIOLATION - Formal
                $r = 20 + $this->q; // VIOLATION - Local
                for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                    $r += $this->q;
                }
            }
        }

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

        Avoid variables with short names like $id. Configured minimum length is 3.
        Open

                        $id = $row['id'];

        ShortVariable

        Since: 0.2

        Detects when a field, local, or parameter has a very short name.

        Example

        class Something {
            private $q = 15; // VIOLATION - Field
            public static function main( array $as ) { // VIOLATION - Formal
                $r = 20 + $this->q; // VIOLATION - Local
                for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                    $r += $this->q;
                }
            }
        }

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

        Avoid variables with short names like $to. Configured minimum length is 3.
        Open

            public function convertFromTo($amount, $from, $to, $date = false)

        ShortVariable

        Since: 0.2

        Detects when a field, local, or parameter has a very short name.

        Example

        class Something {
            private $q = 15; // VIOLATION - Field
            public static function main( array $as ) { // VIOLATION - Formal
                $r = 20 + $this->q; // VIOLATION - Local
                for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                    $r += $this->q;
                }
            }
        }

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

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

            {

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

                        $bank->getRates($otherCurrencyCode, $dateCur, false);

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

                }

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

                    $db->createCommand()->update('yetiforce_currencyupdate_banks', ['active' => 1], ['bank_name' => 'NBP'])->execute();

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

                    'bank_id' => $bankId,

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

            /**

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

             * @param <Integer> $currencyId   - systems currency id

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

             * @return string - currency name

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

             * Returns list of active currencies in CRM.

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

                $notifyNewRates = false;

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

                    while ($row = $dataReader->read()) {

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

                    $dataReader->close();

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

                        ->where(['exchange_date' => $dateCur, 'currency_id' => $currIds, 'bank_id' => $selectBankId])

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

                        $db->createCommand()->delete('yetiforce_currencyupdate_banks', ['id' => $id])->execute();

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

                    $isExists = (new \App\Db\Query())->from('yetiforce_currencyupdate_banks')->where(['bank_name' => $bankClassName])->exists();

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

            /**

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

            public static function getCleanInstance()

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

            {

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

             * @param <Date> $date    - date for which to fetch exchange rates

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

            public function fetchCurrencyRates($dateCur, $cron = false)

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

                $numToConvert = $dataReader->count();

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

                        $code = $row['currency_code'];

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

                    if (!$isExists) {

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

             * @param <Integer> $id       - exchange rate id

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

            }

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

             */

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

                    'fetch_date' => date('Y-m-d'),

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

                return new self();

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

                return (new \App\Db\Query())

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

             * @param bool   $cron    - true if fired by server, and so updates systems currency conversion rates

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

             * @return bool - true if fetched new exchange rates, false otherwise

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

                if (!\App\RequestUtil::isNetConnection()) {

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

                if (!$this->getActiveBankId()) {

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

             * Update currency rate in archives.

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

             *

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

            }

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

             *

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

             */

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

                    $activeBankName = 'Settings_CurrencyUpdate_' . $this->getActiveBankName() . '_BankModel';

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

                    // download only if its not in archives

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

                    if ($currNum != $numToConvert && class_exists($activeBankName)) {

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

                $db = App\Db::getInstance();

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

                while ($row = $dataReader->read()) {

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

                }

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

             */

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

             * @param <Integer> $bankId       - bank id

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

                ])->execute();

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

             */

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

            public static function getCRMCurrencyName($code)

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

            }

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

                    $currIds = [];

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

                    $id = $row['id'];

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

                foreach (new DirectoryIterator(ROOT_DIRECTORY . '/modules/Settings/CurrencyUpdate/bankmodels/') as $fileInfo) {

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

            /**

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

                    'exchange_date' => $exchangeDate,

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

            }

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

            {

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

             * @param mixed  $dateCur

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

             *

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

                    }

        Line exceeds 120 characters; contains 138 characters
        Open

                        $db->createCommand()->insert('yetiforce_currencyupdate_banks', ['bank_name' => $bankClassName, 'active' => 0])->execute();

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

            public function addCurrencyRate($currId, $exchangeDate, $exchange, $bankId)

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

             * Returns currency exchange rate id.

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

                    ->from('vtiger_currencies')

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

                return \count(\App\Fields\Currency::getAll(true));

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

                        ->count(1);

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

                        $notifyNewRates = true;

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

                }

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

            public function refreshBanks()

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

                }

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

            }

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

             *

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

                $dataReader = (new \App\Db\Query())->select(['id', 'currency_code'])

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

                        $otherCurrencyCode[$code] = $id;

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

            {

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

             *

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

            /**

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

             * Returns CRMS active currency name by currency code.

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

                    ->scalar();

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

            public function getCurrencyNum()

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

             * Returns currency exchange rates for systems active currencies from bank.

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

                }

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

                    }

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

            // Synchronises database banks list with the bank classes existing on ftp

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

                    }

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

                    $bankClassName = $fileInfo->getBasename('.php');

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

                    }

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

             * @param <Float>   $exchange - exchange rate

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

             * @param <Float>   $exchange     - exchange rate

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

             * @param <Date>    $exchangeDate - date of exchange rate

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

            // Returns objects instance

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

             */

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

                        $bank = new $activeBankName();

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

                    if (!file_exists($bankPath)) { // delete bank from database

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

                        continue;

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

                    ->execute();

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

                \App\Db::getInstance()->createCommand()->insert('yetiforce_currencyupdate', [

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

                    'currency_id' => $currId,

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

                    ->andWhere(['<>', 'defaultid', -11])->createCommand()->query();

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

            {

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

                    ->from('yetiforce_currencyupdate_banks')

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

                    ->createCommand()->query();

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

                    }

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

                    if (!$fileInfo->isFile() || 'php' !== $fileInfo->getExtension()) {

        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\Db::getInstance()->createCommand()

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

                    ->update('yetiforce_currencyupdate', ['exchange' => $exchange], ['id' => $id])

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

             *

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

            /**

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

            {

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

                    $selectBankId = $this->getActiveBankId();

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

                    $bankPath = ROOT_DIRECTORY . "/modules/Settings/CurrencyUpdate/bankmodels/{$row['bank_name']}.php";

        Line exceeds 120 characters; contains 127 characters
        Open

                    $db->createCommand()->update('yetiforce_currencyupdate_banks', ['active' => 1], ['bank_name' => 'NBP'])->execute();

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

            }

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

             * @return <Integer> - number of currencies

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

                        $currIds[] = $id;

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

                return $notifyNewRates;

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

            }

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

                $dataReader = (new \App\Db\Query())->select(['id', 'bank_name'])

        Line exceeds 120 characters; contains 136 characters
        Open

                    $isExists = (new \App\Db\Query())->from('yetiforce_currencyupdate_banks')->where(['bank_name' => $bankClassName])->exists();

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

             *

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

             * @param <Integer> $bankId       - id of bank

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

             * @param mixed $code

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

                    ->select(['currency_name'])

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

             *

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

                    ->where(['currency_status' => 'Active', 'deleted' => 0])

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

                if ($numToConvert >= 1) {

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

                        $id = $row['id'];

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

                    $currNum = (new \App\Db\Query())->from('yetiforce_currencyupdate')

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

                        $db->createCommand()->insert('yetiforce_currencyupdate_banks', ['bank_name' => $bankClassName, 'active' => 0])->execute();

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

             * Adds currency exchange rate to archive.

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

             * @param <Integer> $currId       - currency id

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

                    ->where(['currency_code' => $code])

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

            /**

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

                    return false;

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

                    ->from('vtiger_currency_info')

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

                    $otherCurrencyCode = [];

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

                $dataReader->close();

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

            public function updateCurrencyRate($id, $exchange)

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

             * @param <Date>    $exchangeDate - exchange date

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

                    'exchange' => $exchange,

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

                    ->from('yetiforce_currencyupdate')

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

             *

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

            public function getRatesHistory($bankId, $dateCur, App\Request $request)

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

             * @return <Array> - array of supported currencies

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

            public function getSupportedCurrencies($bankName = null)

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

                if (!$bankName) {

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

            public function setCRMConversionRate($currency, $exchange)

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

                    if ($from != $mainCurrencyCode) {

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

                            ->from('vtiger_currency_info')

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

            /**

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

                if (!\App\RequestUtil::isNetConnection()) {

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

                }

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

                    $bank = new $bankName();

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

            }

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

                    $unsupported[$name] = $code;

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

             * Sets systems exchange rate for chosen currency.

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

             * @param string  $currency - currency code

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

                    $query->select(['conversion_rate'])

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

                    ->innerJoin('vtiger_currency_info', 'vtiger_currency_info.id = yetiforce_currencyupdate.currency_id')

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

                // filter by date - if not exists then display this months history

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

            /**

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

            /**

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

                }

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

             * @param <Float> $exchange - exchange rate

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

                        $query = new App\Db\Query();

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

            }

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

                    if (\App\RequestUtil::isNetConnection()) {

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

                }

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

                            ->innerJoin('vtiger_currency_info', 'vtiger_currency_info.id = yetiforce_currencyupdate.currency_id AND deleted = :del', [':del' => 0])

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

             * @param string $to   - currency code or id (converted to code)

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

                if (empty($date)) {

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

                        ->where(['currency_code' => $to])

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

                                'yetiforce_currencyupdate.bank_id' => $activeBankId,

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

                try {

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

                }

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

                    return [];

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

            /**

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

             *

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

             */

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

            {

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

                $rate = (float) $exchange;

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

                if (is_numeric($to)) {

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

                    $to = \App\Fields\Currency::getAll(true)[$to]['currency_code'];

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

                        ->limit(1);

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

                            ->where(['yetiforce_currencyupdate.exchange_date' => $date,

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

             * @return <Integer> - currency rate id

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

            {

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

                    ->scalar();

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

            {

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

            {

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

            }

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

             *

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

                    }

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

                        $query->from('yetiforce_currencyupdate')

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

             *

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

                    ->from('yetiforce_currencyupdate')

        Line exceeds 120 characters; contains 129 characters
        Open

                    ->innerJoin('yetiforce_currencyupdate_banks', 'yetiforce_currencyupdate_banks.id = yetiforce_currencyupdate.bank_id')

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

             * @param \App\Request $request

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

                if ($request->isEmpty('duedate') && $dateCur) {

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

                    ->innerJoin('yetiforce_currencyupdate_banks', 'yetiforce_currencyupdate_banks.id = yetiforce_currencyupdate.bank_id')

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

            {

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

             *

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

                $supported = $bank->getSupportedCurrencies($bankName);

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

                    ->execute();

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

             * @param string $bankName - bank name

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

             * @return <Float> - conversion rate

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

                }

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

                    $from = \App\Fields\Currency::getAll(true)[$from]['currency_code'];

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

                    ->where(['currency_status' => 'Active', 'deleted' => 0])

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

                        ->from('vtiger_currency_info')

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

                    ->createCommand()->query();

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

            {

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

                            ->limit(1);

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

                        $fromExchange = (float) ($query->scalar());

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

                        $exchange = 1 / ($fromExchange * $convertToMainCurrency);

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

                        $query = new App\Db\Query();

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

                return (new \App\Db\Query())->select(['id'])

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

             * Returns currency rates from archive.

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

             *

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

             * @param <Integer>    $bankId  - bank id

        Line exceeds 120 characters; contains 143 characters
        Open

                $query = (new App\Db\Query())->select(['exchange', 'currency_name', 'currency_code', 'currency_symbol', 'fetch_date', 'exchange_date'])

        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

                    $query->andWhere(['exchange_date' => $dateCur]);

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

                return $query->orderBy(['exchange_date' => SORT_DESC, 'currency_code' => SORT_ASC])->all();

        Line exceeds 120 characters; contains 122 characters
        Open

                    \App\Log::error('Error during downloading table: ' . PHP_EOL . $ex->__toString() . PHP_EOL, 'CurrencyUpdate');

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

                return $currencies;

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

                if (!$bankName) {

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

                $dataReader = (new \App\Db\Query())->select(['currency_name', 'currency_code'])

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

                    ->from('vtiger_currency_info')

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

             * @param string $from - currency code or id (converted to code)

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

             *

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

                }

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

                    $query = new App\Db\Query();

        Line exceeds 120 characters; contains 155 characters
        Open

                            ->innerJoin('vtiger_currency_info', 'vtiger_currency_info.id = yetiforce_currencyupdate.currency_id AND deleted = :del', [':del' => 0])

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

                $query = (new App\Db\Query())->select(['exchange', 'currency_name', 'currency_code', 'currency_symbol', 'fetch_date', 'exchange_date'])

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

                    $bankName = 'Settings_CurrencyUpdate_' . $this->getActiveBankName() . '_BankModel';

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

             * @return <Array> - array of unsupported currencies

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

            public function getUnSupportedCurrencies($bankName = null)

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

                    $bankName = 'Settings_CurrencyUpdate_' . $this->getActiveBankName() . '_BankModel';

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

                $bank = new $bankName();

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

            public function getCurrencyRateId($currencyId, $exchangeDate, $bankId)

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

                while ($row = $dataReader->read()) {

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

                    ->where(['exchange_date' => $exchangeDate, 'currency_id' => $currencyId, 'bank_id' => $bankId])

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

             * Function that retrieves conversion rate from and to specified currency.

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

             * @param <Date> $date - date of the exchange rate

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

                if (is_numeric($from)) {

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

                        $convertToMainCurrency = 1 / $exchange;

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

             * @return <Array> - array containing currency rates

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

                            ->where(['currency_code' => $from])

        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

                    \App\Log::error('Error during downloading table: ' . PHP_EOL . $ex->__toString() . PHP_EOL, 'CurrencyUpdate');

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

             *

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

                    $name = $row['currency_name'];

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

                    ->update('vtiger_currency_info', ['conversion_rate' => $rate], ['currency_code' => $currency])

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

             */

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

            }

        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\Db::getInstance()->createCommand()

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

            public function getCRMConversionRate($from, $to, $date = '')

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

                    $exchange = (float) ($query->scalar());

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

                    ->where(['yetiforce_currencyupdate.bank_id' => $bankId]);

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

             * Returns list of supported currencies by active bank.

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

             * @param string $bankName - bank name

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

                    return [];

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

                } catch (\Throwable $ex) {

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

                $activeBankId = self::getActiveBankId();

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

                $exchange = false;

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

                } // get conversion rate from archive

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

             * @param <Date>       $dateCur - date, if empty show this months history

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

             */

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

                    $currencies = $bank->getSupportedCurrencies();

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

             *

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

                if (!\App\RequestUtil::isNetConnection()) {

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

                    $code = $row['currency_code'];

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

                $dataReader->close();

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

            }

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

                        $query->select(['conversion_rate'])

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

             *

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

                $currencies = [];

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

             */

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

             */

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

                }

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

                return array_diff($unsupported, $supported);

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

                    $query->andWhere(['between', 'exchange_date', date('Y-m-01'), date('Y-m-t')]);

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

            /**

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

             * Returns list of unsupported currencies by active bank.

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

                }

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

             */

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

                $mainCurrencyCode = \App\Fields\Currency::getDefault()['currency_code'];

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

                // get present conversion rate from crm

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

                        // no exchange rate in archive, fetch new rates

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

                        }

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

             * Convert given amount in one currency to another.

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

                if ($result) {

        Line exceeds 120 characters; contains 151 characters
        Open

                        ->innerJoin('vtiger_currency_info', 'vtiger_currency_info.id = yetiforce_currencyupdate.currency_id AND deleted = :del', [':del' => 0])

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

                        ->where(['yetiforce_currencyupdate.exchange_date' => $date,

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

                                'vtiger_currency_info.currency_code' => $from, ])

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

                        if ($from != $mainCurrencyCode && $to != $mainCurrencyCode) {

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

                    }

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

                    $query = new App\Db\Query();

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

             * Returns id of active bank.

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

             *

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

                $result = $db->createCommand()->update('yetiforce_currencyupdate_banks', ['active' => 1], ['id' => $bankId])->execute();

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

            }

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

                        if (0 == $num) {

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

             * @param string  $from   - currency code

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

            /**

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

                return (new \App\Db\Query())->select(['id'])->from('yetiforce_currencyupdate_banks')->where(['active' => 1])->scalar();

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

            }

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

                $db = \App\Db::getInstance();

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

                return false;

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

             * Returns active banks name.

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

                        }

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

             * @param string  $to     - currency code

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

                        ->innerJoin('vtiger_currency_info', 'vtiger_currency_info.id = yetiforce_currencyupdate.currency_id AND deleted = :del', [':del' => 0])

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

                    $exchange = (float) ($query->scalar());

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

                    if ($from != $mainCurrencyCode) {

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

                            ->from('yetiforce_currencyupdate')

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

                }

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

            {

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

            /**

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

                }

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

             */

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

            {

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

                        ->from('yetiforce_currencyupdate')

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

             *

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

                    $query->select(['yetiforce_currencyupdate.exchange'])

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

                        $query = new App\Db\Query();

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

                                'vtiger_currency_info.currency_code' => $to, ])

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

            }

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

                            'yetiforce_currencyupdate.bank_id' => $activeBankId,

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

             * @return <Float> - floating point number

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

                    }

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

                        $convertToMainCurrency = 0 == $exchange ? 1 : 1 / $exchange;

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

                            ->limit(1);

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

                            $exchange = $fromExchange / $convertToMainCurrency;

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

                            $exchange = $fromExchange * $convertToMainCurrency;

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

                return $exchange = round($exchange, 5);

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

            public function convertFromTo($amount, $from, $to, $date = false)

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

             * @param <Integer> $bankId - bank id

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

            public function getActiveBankName()

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

                            ->limit(1);

        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

             * @param <Float> $amount - number to convert

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

             * @param <Date>  $date   - date of the exchange rate

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

             * @return <Integer> - bank id

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

            /**

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

                            self::fetchCurrencyRates($date);

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

                            ->innerJoin('vtiger_currency_info', 'vtiger_currency_info.id = yetiforce_currencyupdate.currency_id AND deleted = :del', [':del' => 0])

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

             *

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

                    return true;

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

                        $exchange = 1 / $exchange;

        Line exceeds 120 characters; contains 155 characters
        Open

                            ->innerJoin('vtiger_currency_info', 'vtiger_currency_info.id = yetiforce_currencyupdate.currency_id AND deleted = :del', [':del' => 0])

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

                        $fromExchange = (float) ($query->scalar());

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

            }

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

            public function getActiveBankId()

        Line exceeds 120 characters; contains 127 characters
        Open

                return (new \App\Db\Query())->select(['id'])->from('yetiforce_currencyupdate_banks')->where(['active' => 1])->scalar();

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

             * @return bool - true on success or false

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

            public function setActiveBankById($bankId)

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

             * @return string - bank name

        Line exceeds 120 characters; contains 134 characters
        Open

                return (new \App\Db\Query())->select(['bank_name'])->from('yetiforce_currencyupdate_banks')->where(['active' => 1])->scalar();

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

                $db->createCommand()->update('yetiforce_currencyupdate_banks', ['active' => 0])->execute();

        Line exceeds 120 characters; contains 128 characters
        Open

                $result = $db->createCommand()->update('yetiforce_currencyupdate_banks', ['active' => 1], ['id' => $bankId])->execute();

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

             *

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

                    if ($exchange > 0) {

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

            /**

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

             */

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

                return round($amount * $this->getCRMConversionRate($from, $to, $date), 5);

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

             *

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

             * Saves new active bank by id.

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

             */

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

                return (new \App\Db\Query())->select(['bank_name'])->from('yetiforce_currencyupdate_banks')->where(['active' => 1])->scalar();

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

            }

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

                            ->where(['yetiforce_currencyupdate.exchange_date' => $date,

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

                                'yetiforce_currencyupdate.bank_id' => $activeBankId,

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

                    }

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

             *

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

            {

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

            {

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

                        $num = (float) ($query->count());

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

                            'vtiger_currency_info.currency_code' => $to, ])

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

                        ->limit(1);

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

                        $query->select(['yetiforce_currencyupdate.exchange'])

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

             */

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

        class Settings_CurrencyUpdate_Module_Model extends \App\Base

        There are no issues that match your filters.

        Category
        Status