YetiForceCompany/YetiForceCRM

View on GitHub
tests/Base/Z_StringFormatting.php

Summary

Maintainability
B
5 hrs
Test Coverage
A
100%

Method appendDouble has 71 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function appendDouble(&$combinations)
    {
        $int = '123456789';
        $fieldData = (new \App\Db\Query())->from('vtiger_field')->where(['uitype' => 7, 'typeofdata' => 'NN~O'])->one();
        foreach ($this->getCombinations() as $combination) {
Severity: Major
Found in tests/Base/Z_StringFormatting.php - About 2 hrs to fix

    Method testNumbers has 11 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        public function testNumbers($moduleName, $fieldName, $userFormat, $dbFormat, $decimalSeparator, $groupingSeparator, $groupingPattern, $afterDot, $symbolPlacement, $truncate, $correct = true): void
    Severity: Major
    Found in tests/Base/Z_StringFormatting.php - About 1 hr to fix

      Method appendInteger has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function appendInteger(&$combinations)
          {
              $dbFormat = '123456789';
              $fieldData = (new \App\Db\Query())->from('vtiger_field')->where(['uitype' => 7])->one();
              foreach ($this->getCombinations() as $combination) {
      Severity: Minor
      Found in tests/Base/Z_StringFormatting.php - About 1 hr to fix

        Function getCombinations has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function getCombinations()
            {
                if (!self::$combinations) {
                    $query = (new \App\Db\Query())->select(
                        [
        Severity: Minor
        Found in tests/Base/Z_StringFormatting.php - About 25 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 testNumbers has 11 parameters. Consider reducing the number of parameters to less than 10.
        Open

            public function testNumbers($moduleName, $fieldName, $userFormat, $dbFormat, $decimalSeparator, $groupingSeparator, $groupingPattern, $afterDot, $symbolPlacement, $truncate, $correct = true): void
            {
                $userModel = \Vtiger_Record_Model::getInstanceById(\App\User::getCurrentUserId(), 'Users');
                $userModel->set('currency_decimal_separator', $decimalSeparator);
                $userModel->set('currency_grouping_separator', $groupingSeparator);
        Severity: Minor
        Found in tests/Base/Z_StringFormatting.php by phpmd

        This function has 11 parameters, which is greater than the 7 authorized.
        Open

            public function testNumbers($moduleName, $fieldName, $userFormat, $dbFormat, $decimalSeparator, $groupingSeparator, $groupingPattern, $afterDot, $symbolPlacement, $truncate, $correct = true): void
        Severity: Major
        Found in tests/Base/Z_StringFormatting.php by sonar-php

        A long parameter list can indicate that a new structure should be created to wrap the numerous parameters or that the function is doing too many things.

        Noncompliant Code Example

        With a maximum number of 4 parameters:

        function doSomething($param1, $param2, $param3, $param4, $param5) {
        ...
        }
        

        Compliant Solution

        function doSomething($param1, $param2, $param3, $param4) {
        ...
        }
        

        Missing class import via use statement (line '128', column '21').
        Open

                $fieldData = (new \App\Db\Query())->from('vtiger_field')->where(['uitype' => 7])->one();
        Severity: Minor
        Found in tests/Base/Z_StringFormatting.php by phpmd

        MissingImport

        Since: 2.7.0

        Importing all external classes in a file through use statements makes them clearly visible.

        Example

        function make() {
            return new \stdClass();
        }

        Source http://phpmd.org/rules/cleancode.html#MissingImport

        The method testNumbers has a boolean flag argument $correct, which is a certain sign of a Single Responsibility Principle violation.
        Open

            public function testNumbers($moduleName, $fieldName, $userFormat, $dbFormat, $decimalSeparator, $groupingSeparator, $groupingPattern, $afterDot, $symbolPlacement, $truncate, $correct = true): void
        Severity: Minor
        Found in tests/Base/Z_StringFormatting.php by phpmd

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

                    $query = (new \App\Db\Query())->select(
        Severity: Minor
        Found in tests/Base/Z_StringFormatting.php by phpmd

        MissingImport

        Since: 2.7.0

        Importing all external classes in a file through use statements makes them clearly visible.

        Example

        function make() {
            return new \stdClass();
        }

        Source http://phpmd.org/rules/cleancode.html#MissingImport

        Missing class import via use statement (line '172', column '21').
        Open

                $fieldData = (new \App\Db\Query())->from('vtiger_field')->where(['uitype' => 7, 'typeofdata' => 'NN~O'])->one();
        Severity: Minor
        Found in tests/Base/Z_StringFormatting.php by phpmd

        MissingImport

        Since: 2.7.0

        Importing all external classes in a file through use statements makes them clearly visible.

        Example

        function make() {
            return new \stdClass();
        }

        Source http://phpmd.org/rules/cleancode.html#MissingImport

        Avoid using static access to class '\App\User' in method 'setUpBeforeClass'.
        Open

                $userModel = \App\User::getCurrentUserModel();
        Severity: Minor
        Found in tests/Base/Z_StringFormatting.php by phpmd

        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\Module' in method 'appendInteger'.
        Open

                        \App\Module::getModuleName($fieldData['tabid']),
        Severity: Minor
        Found in tests/Base/Z_StringFormatting.php by phpmd

        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\Module' in method 'appendDouble'.
        Open

                        \App\Module::getModuleName($fieldData['tabid']),
        Severity: Minor
        Found in tests/Base/Z_StringFormatting.php by phpmd

        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\Module' in method 'appendDouble'.
        Open

                        \App\Module::getModuleName($fieldData['tabid']),
        Severity: Minor
        Found in tests/Base/Z_StringFormatting.php by phpmd

        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 '\Vtiger_Record_Model' in method 'testNumbers'.
        Open

                $userModel = \Vtiger_Record_Model::getInstanceById(\App\User::getCurrentUserId(), 'Users');
        Severity: Minor
        Found in tests/Base/Z_StringFormatting.php by phpmd

        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\Module' in method 'appendInteger'.
        Open

                        \App\Module::getModuleName($fieldData['tabid']),
        Severity: Minor
        Found in tests/Base/Z_StringFormatting.php by phpmd

        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\Module' in method 'appendDouble'.
        Open

                        \App\Module::getModuleName($fieldData['tabid']),
        Severity: Minor
        Found in tests/Base/Z_StringFormatting.php by phpmd

        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\User' in method 'testNumbers'.
        Open

                $userModel = \Vtiger_Record_Model::getInstanceById(\App\User::getCurrentUserId(), 'Users');
        Severity: Minor
        Found in tests/Base/Z_StringFormatting.php by phpmd

        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\Module' in method 'appendDouble'.
        Open

                        \App\Module::getModuleName($fieldData['tabid']),
        Severity: Minor
        Found in tests/Base/Z_StringFormatting.php by phpmd

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

                    } else {
                        $this->fail('Unsupported field type: ' . \ucfirst($type));
                    }
        Severity: Minor
        Found in tests/Base/Z_StringFormatting.php by phpmd

        ElseExpression

        Since: 1.4.0

        An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

        Example

        class Foo
        {
            public function bar($flag)
            {
                if ($flag) {
                    // one branch
                } else {
                    // another branch
                }
            }
        }

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

        Avoid using static access to class '\Vtiger_Record_Model' in method 'tearDownAfterClass'.
        Open

                $userModel = \Vtiger_Record_Model::getInstanceById(\App\User::getCurrentUserId(), 'Users');
        Severity: Minor
        Found in tests/Base/Z_StringFormatting.php by phpmd

        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 '\Vtiger_Record_Model' in method 'testNumbers'.
        Open

                $recordModel = \Vtiger_Record_Model::getCleanInstance($moduleName);
        Severity: Minor
        Found in tests/Base/Z_StringFormatting.php by phpmd

        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\User' in method 'tearDownAfterClass'.
        Open

                $userModel = \Vtiger_Record_Model::getInstanceById(\App\User::getCurrentUserId(), 'Users');
        Severity: Minor
        Found in tests/Base/Z_StringFormatting.php by phpmd

        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 "grouping_separator" 11 times.
        Open

                            'grouping_separator' => 'vtiger_currency_grouping_separator.currency_grouping_separator',
        Severity: Critical
        Found in tests/Base/Z_StringFormatting.php by sonar-php

        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_decimal_separator" 3 times.
        Open

                self::$separatorDecimal = $userModel->getDetail('currency_decimal_separator');
        Severity: Critical
        Found in tests/Base/Z_StringFormatting.php by sonar-php

        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_symbol_placement" 3 times.
        Open

                self::$symbolPlacement = $userModel->getDetail('currency_symbol_placement');
        Severity: Critical
        Found in tests/Base/Z_StringFormatting.php by sonar-php

        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_grouping_separator" 3 times.
        Open

                self::$separatorGrouping = $userModel->getDetail('currency_grouping_separator');
        Severity: Critical
        Found in tests/Base/Z_StringFormatting.php by sonar-php

        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 "fieldname" 6 times.
        Open

                        $fieldData['fieldname'],
        Severity: Critical
        Found in tests/Base/Z_StringFormatting.php by sonar-php

        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 "truncate_trailing_zeros" 3 times.
        Open

                self::$truncateTrailingZeros = $userModel->getDetail('truncate_trailing_zeros');
        Severity: Critical
        Found in tests/Base/Z_StringFormatting.php by sonar-php

        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 "grouping_pattern" 10 times.
        Open

                            'grouping_pattern' => 'vtiger_currency_grouping_pattern.currency_grouping_pattern',
        Severity: Critical
        Found in tests/Base/Z_StringFormatting.php by sonar-php

        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 "decimal_separator" 12 times.
        Open

                            'decimal_separator' => 'vtiger_currency_decimal_separator.currency_decimal_separator',
        Severity: Critical
        Found in tests/Base/Z_StringFormatting.php by sonar-php

        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 "cross join" 4 times.
        Open

                    )->from('vtiger_currency_decimal_separator')->join('cross join', 'vtiger_currency_grouping_pattern')->join('cross join', 'vtiger_currency_grouping_separator')->join('cross join', 'vtiger_currency_symbol_placement')->join('cross join', 'vtiger_no_of_currency_decimals')->createCommand()->query();
        Severity: Critical
        Found in tests/Base/Z_StringFormatting.php by sonar-php

        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 "tabid" 6 times.
        Open

                        \App\Module::getModuleName($fieldData['tabid']),
        Severity: Critical
        Found in tests/Base/Z_StringFormatting.php by sonar-php

        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.

        Rename "$combinations" which has the same name as the field declared at line 47.
        Open

                $combinations = [];
        Severity: Major
        Found in tests/Base/Z_StringFormatting.php by sonar-php

        Shadowing fields with a local variable is a bad practice that reduces code readability: it makes it confusing to know whether the field or the variable is being used.

        Noncompliant Code Example

        class Foo {
          public $myField;
        
          public function doSomething() {
            $myField = 0;
            ...
          }
        }
        

        See

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

                self::$decimalNum = $userModel->getDetail('no_of_currency_decimals');
        Severity: Critical
        Found in tests/Base/Z_StringFormatting.php by sonar-php

        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 "decimals" 9 times.
        Open

                            'decimals' => 'vtiger_no_of_currency_decimals.no_of_currency_decimals',
        Severity: Critical
        Found in tests/Base/Z_StringFormatting.php by sonar-php

        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 "symbol_placement" 7 times.
        Open

                            'symbol_placement' => 'vtiger_currency_symbol_placement.currency_symbol_placement',
        Severity: Critical
        Found in tests/Base/Z_StringFormatting.php by sonar-php

        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_grouping_pattern" 3 times.
        Open

                self::$patternGrouping = $userModel->getDetail('currency_grouping_pattern');
        Severity: Critical
        Found in tests/Base/Z_StringFormatting.php by sonar-php

        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 '$correct'.
        Open

            public function testNumbers($moduleName, $fieldName, $userFormat, $dbFormat, $decimalSeparator, $groupingSeparator, $groupingPattern, $afterDot, $symbolPlacement, $truncate, $correct = true): void
        Severity: Minor
        Found in tests/Base/Z_StringFormatting.php by phpmd

        UnusedFormalParameter

        Since: 0.2

        Avoid passing parameters to methods or constructors and then not using those parameters.

        Example

        class Foo
        {
            private function bar($howdy)
            {
                // $howdy is not used
            }
        }

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

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

                $fieldData = (new \App\Db\Query())->from('vtiger_field')->where(['uitype' => 7])->one();
        Severity: Critical
        Found in tests/Base/Z_StringFormatting.php by phan

        Static call to undeclared method \Tests\Base::tearDownAfterClass
        Open

                parent::tearDownAfterClass();
        Severity: Critical
        Found in tests/Base/Z_StringFormatting.php by phan

        Argument 1 (str) is 12312 but \substr() takes string
        Open

                    $decimals = \substr(12312, 0, $combination['decimals']);
        Severity: Minor
        Found in tests/Base/Z_StringFormatting.php by phan

        Call to undeclared method \Tests\Base\Z_StringFormatting::fail
        Open

                        $this->fail('Unsupported field type: ' . \ucfirst($type));
        Severity: Critical
        Found in tests/Base/Z_StringFormatting.php by phan

        Argument 1 (str) is 10000 but \substr() takes string
        Open

                    $decimals = \substr(10000, 0, $combination['decimals']);
        Severity: Minor
        Found in tests/Base/Z_StringFormatting.php by phan

        Call to undeclared method \Tests\Base\Z_StringFormatting::assertSame
        Open

                $this->assertSame($dbFormat, $recordModel->get($fieldName), 'Database value different than expected | ' . $dbFormat . ' !== ' . $recordModel->get($fieldName));
        Severity: Critical
        Found in tests/Base/Z_StringFormatting.php by phan

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

                    $query = (new \App\Db\Query())->select(
        Severity: Critical
        Found in tests/Base/Z_StringFormatting.php by phan

        Call to method getCurrentUserModel from undeclared class \App\User (Did you mean class \Tests\App\User)
        Open

                $userModel = \App\User::getCurrentUserModel();
        Severity: Critical
        Found in tests/Base/Z_StringFormatting.php by phan

        Call to method getCurrentUserId from undeclared class \App\User (Did you mean class \Tests\App\User)
        Open

                $userModel = \Vtiger_Record_Model::getInstanceById(\App\User::getCurrentUserId(), 'Users');
        Severity: Critical
        Found in tests/Base/Z_StringFormatting.php by phan

        Call to method getCurrentUserId from undeclared class \App\User (Did you mean class \Tests\App\User)
        Open

                $userModel = \Vtiger_Record_Model::getInstanceById(\App\User::getCurrentUserId(), 'Users');
        Severity: Critical
        Found in tests/Base/Z_StringFormatting.php by phan

        Static call to undeclared method \Tests\Base::setUpBeforeClass
        Open

                parent::setUpBeforeClass();
        Severity: Critical
        Found in tests/Base/Z_StringFormatting.php by phan

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

                $fieldData = (new \App\Db\Query())->from('vtiger_field')->where(['uitype' => 7, 'typeofdata' => 'NN~O'])->one();
        Severity: Critical
        Found in tests/Base/Z_StringFormatting.php by phan

        Call to undeclared method \Tests\Base\Z_StringFormatting::assertSame
        Open

                $this->assertSame($userFormat, $recordModel->getDisplayValue($fieldName), 'Display value different than expected ' . $recordModel->get($fieldName) . " !== $dbFormat | userFormat: $userFormat | fieldName: $fieldName | getDisplayValue: " . $recordModel->getDisplayValue($fieldName));
        Severity: Critical
        Found in tests/Base/Z_StringFormatting.php by phan

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

            public static $truncateTrailingZeros;
        Severity: Minor
        Found in tests/Base/Z_StringFormatting.php by phpmd

        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

        The class Z_StringFormatting is not named in CamelCase.
        Open

        class Z_StringFormatting extends \Tests\Base
        {
            /**
             * @var string Decimal numbers separator
             */
        Severity: Minor
        Found in tests/Base/Z_StringFormatting.php by phpmd

        CamelCaseClassName

        Since: 0.2

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

        Example

        class class_name {
        }

        Source

        Space found after opening bracket of FOREACH loop
        Open

                foreach (

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

            public function getCombinations()

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

                            'decimal_separator' => 'vtiger_currency_decimal_separator.currency_decimal_separator',

        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 appendInteger(&$combinations)

        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

            public static $truncateTrailingZeros;

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

            public static $combinations = [];

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

                self::$decimalNum = $userModel->getDetail('no_of_currency_decimals');

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

             *

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

                foreach (

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

                        $this->{$method}($combinations);

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

                    }

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

                            'grouping_separator' => 'vtiger_currency_grouping_separator.currency_grouping_separator',

        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

                self::$truncateTrailingZeros = $userModel->getDetail('truncate_trailing_zeros');

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

            public static function setUpBeforeClass(): void

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

             * Data provider for the numbers formatting test.

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

            /**

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

                $combinations = [];

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

                        $this->fail('Unsupported field type: ' . \ucfirst($type));

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

                    if (\method_exists($this, $method)) {

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

                return self::$combinations;

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

             * @var string Numbers grouping separator

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

             * @var int Decimal places count

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

             * @codeCoverageIgnore

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

                if (!self::$combinations) {

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

                    while ($combination = $query->read()) {

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

            public static $patternGrouping;

        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 $separatorGrouping;

        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

                    ] as $type) {

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

                return $combinations;

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

                self::$separatorGrouping = $userModel->getDetail('currency_grouping_separator');

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

             * Generate list of possible combinations.

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

                            self::$combinations[] = $combination;

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

             * @codeCoverageIgnore

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

             * @param $combinations

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

                self::$separatorDecimal = $userModel->getDetail('currency_decimal_separator');

        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::$patternGrouping = $userModel->getDetail('currency_grouping_pattern');

        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

        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('vtiger_currency_decimal_separator')->join('cross join', 'vtiger_currency_grouping_pattern')->join('cross join', 'vtiger_currency_grouping_separator')->join('cross join', 'vtiger_currency_symbol_placement')->join('cross join', 'vtiger_no_of_currency_decimals')->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

             *

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

             * @var string Numbers grouping pattern

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

             */

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

             * Store current user preferences.

        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

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

            /**

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

             * @var bool Truncate zeros in decimal numbers

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

                parent::setUpBeforeClass();

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

                self::$symbolPlacement = $userModel->getDetail('currency_symbol_placement');

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

                    $method = 'append' . \ucfirst($type);

        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 $separatorDecimal;

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

             */

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

             * @var string Currency symbol placement

        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

                        'double',

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

                }

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

                            'grouping_pattern' => 'vtiger_currency_grouping_pattern.currency_grouping_pattern',

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

                            'decimals' => 'vtiger_no_of_currency_decimals.no_of_currency_decimals',

        Line exceeds 120 characters; contains 307 characters
        Open

                    )->from('vtiger_currency_decimal_separator')->join('cross join', 'vtiger_currency_grouping_pattern')->join('cross join', 'vtiger_currency_grouping_separator')->join('cross join', 'vtiger_currency_symbol_placement')->join('cross join', 'vtiger_no_of_currency_decimals')->createCommand()->query();

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

                        if ($combination['grouping_separator'] !== $combination['decimal_separator']) {

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

             * Append integer validation data sets to test combinations.

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

             * @var string Decimal numbers separator

        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 providerNumbers()

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

             *

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

             * @codeCoverageIgnore

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

             * @var array Possible combinations cache

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

             * @return array

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

                        'integer',

        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

             */

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

                    $query = (new \App\Db\Query())->select(

        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 $symbolPlacement;

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

            public static $decimalNum;

        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

             * @codeCoverageIgnore

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

                $userModel = \App\User::getCurrentUserModel();

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

                            'symbol_placement' => 'vtiger_currency_symbol_placement.currency_symbol_placement',

        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

                        $combination['grouping_separator'],

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

                        $combination['grouping_pattern'],

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

             * @param $combinations

        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

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

                        $fieldData['fieldname'],

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

                        $combination['decimals'],

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

                        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

                $recordModel->set($fieldName, $dbFormat);

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

                        $usrFormat,

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

                        $combination['grouping_separator'],

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

             * @param string $decimalSeparator  Char used as decimal separator in string

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

             * @param string $groupingSeparator Char used to separate groups in string

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

             */

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

                $userModel->set('no_of_currency_decimals', $afterDot);

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

            public static function tearDownAfterClass(): void

        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

                        true,

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

                        true,

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

                    $combinations[] = [

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

                        $combination['grouping_separator'],

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

                    $combinations[] = [

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

                        $combination['symbol_placement'],

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

                        $usrFormat .= $combination['decimal_separator'] . $decimals;

        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 $moduleName        Module name

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

             * @param string $userFormat        Value in user format

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

             * @param bool   $truncate          Truncate zeros after decimal separator

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

                $userModel->save();

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

                $fieldData = (new \App\Db\Query())->from('vtiger_field')->where(['uitype' => 7, 'typeofdata' => 'NN~O'])->one();

        Line exceeds 120 characters; contains 135 characters
        Open

                    $usrFormatTruncated = $usrFormat = \str_replace(',', $combination['grouping_separator'], $combination['grouping_pattern']);

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

                        \App\Module::getModuleName($fieldData['tabid']),

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

                    $combinations[] = [

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

                        $combination['decimals'],

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

                        $fieldData['fieldname'],

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

                        $combination['grouping_pattern'],

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

                        $combination['decimals'],

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

                        $dbFormat,

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

            public function appendDouble(&$combinations)

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

                        $usrFormat .= $combination['decimal_separator'] . $decimals;

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

                    $combinations[] = [

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

                    ];

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

                        $usrFormatTruncated,

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

                $this->assertSame($userFormat, $recordModel->getDisplayValue($fieldName), 'Display value different than expected ' . $recordModel->get($fieldName) . " !== $dbFormat | userFormat: $userFormat | fieldName: $fieldName | getDisplayValue: " . $recordModel->getDisplayValue($fieldName));

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

                $userModel->set('currency_symbol_placement', self::$symbolPlacement);

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

                        $combination['symbol_placement'],

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

                        $combination['symbol_placement'],

        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

                        $usrFormatTruncated .= $combination['decimal_separator'] . rtrim($decimals, '0');

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

                    $usrFormatTruncated = $usrFormat = \str_replace(',', $combination['grouping_separator'], $combination['grouping_pattern']);

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

                        $usrFormatTruncated .= $combination['decimal_separator'] . rtrim($decimals, '0');

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

                        $dbFormat,

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

                        $combination['decimal_separator'],

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

                        $combination['decimals'],

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

                        $combination['symbol_placement'],

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

                return $combinations;

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

            }

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

                $userModel->set('currency_symbol_placement', $symbolPlacement);

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

                $userModel->set('currency_grouping_pattern', $groupingPattern);

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

                $recordModel = \Vtiger_Record_Model::getCleanInstance($moduleName);

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

             */

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

                        $dbFormat,

        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

                foreach ($this->getCombinations() as $combination) {

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

                    $usrFormatTruncated = $usrFormat = \str_replace(',', $combination['grouping_separator'], $combination['grouping_pattern']);

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

                        $fieldData['fieldname'],

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

                        $dbFormat,

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

                        $combination['decimals'],

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

                        \App\Module::getModuleName($fieldData['tabid']),

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

             * @param string $fieldName         Field name

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

                        \App\Module::getModuleName($fieldData['tabid']),

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

                    $dbFormat = $int . '.' . 12312;

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

                        $usrFormatTruncated,

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

             * @param string $groupingPattern   Pattern for grouping

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

                $userModel = \Vtiger_Record_Model::getInstanceById(\App\User::getCurrentUserId(), 'Users');

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

                $userModel = \Vtiger_Record_Model::getInstanceById(\App\User::getCurrentUserId(), 'Users');

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

                    $usrFormatTruncated = $usrFormat = \str_replace(',', $combination['grouping_separator'], $combination['grouping_pattern']);

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

                        \App\Module::getModuleName($fieldData['tabid']),

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

                        $usrFormatTruncated,

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

                $int = '123456789';

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

                        $combination['decimal_separator'],

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

                        true,

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

                        $combination['grouping_separator'],

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

                $userModel->set('currency_decimal_separator', self::$separatorDecimal);

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

                $userModel->set('truncate_trailing_zeros', self::$truncateTrailingZeros);

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

                    $combinations[] = [

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

                        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

             * @codeCoverageIgnore

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

                        $fieldData['fieldname'],

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

                        $combination['decimal_separator'],

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

                        $fieldData['fieldname'],

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

                        false,

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

             * @param string $symbolPlacement   Currency symbol placement in user format

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

             * @dataProvider providerNumbers

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

                $userModel->set('truncate_trailing_zeros', $truncate ? '1' : '0');

        Line exceeds 120 characters; contains 135 characters
        Open

                    $usrFormatTruncated = $usrFormat = \str_replace(',', $combination['grouping_separator'], $combination['grouping_pattern']);

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

                        $combination['decimal_separator'],

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

                        $combination['grouping_separator'],

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

                        \App\Module::getModuleName($fieldData['tabid']),

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

                        $combination['symbol_placement'],

        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 $dbFormat          Value in database format

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

            public function testNumbers($moduleName, $fieldName, $userFormat, $dbFormat, $decimalSeparator, $groupingSeparator, $groupingPattern, $afterDot, $symbolPlacement, $truncate, $correct = true): void

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

            {

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

             * Restore current user preferences.

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

                parent::tearDownAfterClass();

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

                        $usrFormat,

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

                    if ($decimals) {

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

                        true,

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

                        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

                $userModel->set('currency_decimal_separator', $decimalSeparator);

        Line exceeds 120 characters; contains 289 characters
        Open

                $this->assertSame($userFormat, $recordModel->getDisplayValue($fieldName), 'Display value different than expected ' . $recordModel->get($fieldName) . " !== $dbFormat | userFormat: $userFormat | fieldName: $fieldName | getDisplayValue: " . $recordModel->getDisplayValue($fieldName));

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

                        $combination['decimals'],

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

                    }

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

                        true,

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

                        $combination['decimal_separator'],

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

                        $combination['grouping_pattern'],

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

                    ];

        Line exceeds 120 characters; contains 135 characters
        Open

                    $usrFormatTruncated = $usrFormat = \str_replace(',', $combination['grouping_separator'], $combination['grouping_pattern']);

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

                    if ($decimals) {

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

                        $usrFormat,

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

                        $dbFormat,

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

                }

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

             * Numbers conversion tests.

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

             * @param int    $afterDot          Number of chars after decimal separator

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

             * @param bool   $correct           Test should be successfull

        Line exceeds 120 characters; contains 200 characters
        Open

            public function testNumbers($moduleName, $fieldName, $userFormat, $dbFormat, $decimalSeparator, $groupingSeparator, $groupingPattern, $afterDot, $symbolPlacement, $truncate, $correct = true): void

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

                $fieldData = (new \App\Db\Query())->from('vtiger_field')->where(['uitype' => 7])->one();

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

                foreach ($this->getCombinations() as $combination) {

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

                    ];

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

                        $combination['grouping_pattern'],

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

                        $dbFormat,

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

                    ];

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

                    $combinations[] = [

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

                $this->assertSame($dbFormat, $recordModel->get($fieldName), 'Database value different than expected | ' . $dbFormat . ' !== ' . $recordModel->get($fieldName));

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

            /**

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

                $userModel->set('currency_grouping_pattern', self::$patternGrouping);

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

                        $fieldData['fieldname'],

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

                return $combinations;

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

                    $decimals = \substr(12312, 0, $combination['decimals']);

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

                    $decimals = \substr(10000, 0, $combination['decimals']);

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

                        true,

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

                        $combination['grouping_pattern'],

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

                $userModel->save();

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

             *

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

                $dbFormat = '123456789';

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

                        $combination['decimal_separator'],

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

                        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

             * Append double validation data sets to test combinations.

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

                        $combination['symbol_placement'],

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

                        \App\Module::getModuleName($fieldData['tabid']),

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

                        false,

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

                    $dbFormat = $int . '.' . 10000;

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

                        $combination['grouping_separator'],

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

                        $combination['grouping_pattern'],

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

                $userModel->set('currency_grouping_separator', $groupingSeparator);

        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 167 characters
        Open

                $this->assertSame($dbFormat, $recordModel->get($fieldName), 'Database value different than expected | ' . $dbFormat . ' !== ' . $recordModel->get($fieldName));

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

             * @throws \Exception

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

                $userModel->set('currency_grouping_separator', self::$separatorGrouping);

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

                $userModel->set('no_of_currency_decimals', self::$decimalNum);

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

        class Z_StringFormatting extends \Tests\Base

        Expected 0 spaces after opening bracket; newline found
        Open

                foreach (

        There are no issues that match your filters.

        Category
        Status