YetiForceCompany/YetiForceCRM

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

Summary

Maintainability
C
1 day
Test Coverage
F
0%

Function getStats has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

    public function getStats($data, $langBase, $byModule)
    {
        $differences = [];
        $i = 0;
        foreach ($data as $id => $dataLang) {
Severity: Minor
Found in modules/Settings/LangManagement/models/Module.php - About 3 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

The class Settings_LangManagement_Module_Model has an overall complexity of 62 which is very high. The configured complexity threshold is 50.
Open

class Settings_LangManagement_Module_Model extends Settings_Vtiger_Module_Model
{
    const URL_SEPARATOR = '__';

    /**

Function getModFromLang has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public function getModFromLang($lang)
    {
        $modules = [];
        $settings = [];
        $format = \App\Language::FORMAT;
Severity: Minor
Found in modules/Settings/LangManagement/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

Function loadLangTranslation has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public function loadLangTranslation($langs, $moduleName)
    {
        $keysPhp = $keysJs = $langTab = $respPhp = $respJs = [];
        $moduleName = str_replace(self::URL_SEPARATOR, DIRECTORY_SEPARATOR, $moduleName);
        if (!\is_array($langs)) {
Severity: Minor
Found in modules/Settings/LangManagement/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 getStats has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getStats($data, $langBase, $byModule)
    {
        $differences = [];
        $i = 0;
        foreach ($data as $id => $dataLang) {
Severity: Minor
Found in modules/Settings/LangManagement/models/Module.php - About 1 hr to fix

    Function deleteDir has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function deleteDir($dir)
        {
            $fd = opendir($dir);
            if (!$fd) {
                return false;
    Severity: Minor
    Found in modules/Settings/LangManagement/models/Module.php - About 55 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

    Function getStatsData has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getStatsData($langBase, $langs, $byModule = false)
        {
            $filesName = $this->getModFromLang($langBase);
            $langs = (array) $langs;
            if (!\in_array($langBase, $langs)) {
    Severity: Minor
    Found in modules/Settings/LangManagement/models/Module.php - About 45 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

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

        public function loadCustomLanguageFile(array $languages, string $moduleName)
        {
            $result = [];
            $moduleName = str_replace(self::URL_SEPARATOR, DIRECTORY_SEPARATOR, $moduleName);
            foreach ($languages as $language) {
    Severity: Minor
    Found in modules/Settings/LangManagement/models/Module.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 loadLangTranslation() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10.
    Open

        public function loadLangTranslation($langs, $moduleName)
        {
            $keysPhp = $keysJs = $langTab = $respPhp = $respJs = [];
            $moduleName = str_replace(self::URL_SEPARATOR, DIRECTORY_SEPARATOR, $moduleName);
            if (!\is_array($langs)) {

    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

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

        public function getStats($data, $langBase, $byModule)
        {
            $differences = [];
            $i = 0;
            foreach ($data as $id => $dataLang) {

    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 16 to the 15 allowed.
    Open

        public function loadLangTranslation($langs, $moduleName)

    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

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

        public function getStats($data, $langBase, $byModule)

    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

    The class Settings_LangManagement_Module_Model has a coupling between objects value of 13. Consider to reduce the number of dependencies under 13.
    Open

    class Settings_LangManagement_Module_Model extends Settings_Vtiger_Module_Model
    {
        const URL_SEPARATOR = '__';
    
        /**

    CouplingBetweenObjects

    Since: 1.1.0

    A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

    Example

    class Foo {
        /**
         * @var \foo\bar\X
         */
        private $x = null;
    
        /**
         * @var \foo\bar\Y
         */
        private $y = null;
    
        /**
         * @var \foo\bar\Z
         */
        private $z = null;
    
        public function setFoo(\Foo $foo) {}
        public function setBar(\Bar $bar) {}
        public function setBaz(\Baz $baz) {}
    
        /**
         * @return \SplObjectStorage
         * @throws \OutOfRangeException
         * @throws \InvalidArgumentException
         * @throws \ErrorException
         */
        public function process(\Iterator $it) {}
    
        // ...
    }

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

    Missing class import via use statement (line '238', column '23').
    Open

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

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

                    throw new \App\Exceptions\AppException('No permissions to create directories');

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

        public function getStatsData($langBase, $langs, $byModule = 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 '235', column '22').
    Open

                $configFile = new \App\ConfigFile('main');

    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 '119', column '59').
    Open

                foreach ($iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir), RecursiveIteratorIterator::SELF_FIRST) as $object) {

    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

    Duplicated array key name, first declared at line 157.
    Open

            $db->createCommand()->insert('vtiger_language', [
                'name' => $params['name'],
                'prefix' => $params['prefix'],
                'name' => $params['label'],
                'lastupdated' => date('Y-m-d H:i:s')

    DuplicatedArrayKey

    Defining another value for the same key in an array literal overrides the previous key/value, which makes it effectively an unused code. If it's known from the beginning that the key will have different value, there is usually no point in defining first one.

    Example

    function createArray() {
        return [
            'non-associative 0element', // not applied
            0 => 'associative 0-element', // applied
            false => 'associative 0-element', // applied
            'foo' => 'bar', // not applied
            "foo" => 'baz', // applied
        ];
    }

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

    Missing class import via use statement (line '119', column '29').
    Open

                foreach ($iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir), RecursiveIteratorIterator::SELF_FIRST) as $object) {

    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\Language' in method 'loadLangTranslation'.
    Open

                $langData = \App\Language::getFromFile($moduleName, $lang);

    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\Language' in method 'getModFromLang'.
    Open

            $lang = empty($lang) ? \App\Language::getLanguage() : $lang;

    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\Language' in method 'getModFromLang'.
    Open

                            $settings["{$iterator->getSubPath()}__{$name}"] = \App\Language::translate($name, "{$iterator->getSubPath()}.$name");

    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\Validator' in method 'add'.
    Open

            if (!\App\Validator::languageTag($params['prefix'])) {

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

            \App\Log::trace('Entering Settings_LangManagement_Module_Model::setAsDefault(' . $prefix . ') method ...');

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

                            } else {
                                $differences[$lang][] = $key;
                            }

    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\Language' in method 'add'.
    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\Purifier' in method 'loadLangTranslation'.
    Open

                    $respJs[$key][$language] = isset($langTab[$language]['js'][$key]) ? \App\Purifier::encodeHtml($langTab[$language]['js'][$key]) : null;

    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 'vtlib\Functions' in method 'add'.
    Open

            vtlib\Functions::recurseCopy('languages/' . \App\Language::DEFAULT_LANG, $destiny);

    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\Language' in method 'setAsDefault'.
    Open

            if (\App\Language::getLangInfo($prefix)) {

    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\Purifier' in method 'loadLangTranslation'.
    Open

                    $respPhp[$key][$language] = isset($langTab[$language]['php'][$key]) ? \App\Purifier::encodeHtml($langTab[$language]['php'][$key]) : null;

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

                } else {
                    unlink("$dir/$file");
                }

    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\Log' in method 'setAsDefault'.
    Open

            \App\Log::trace('Exiting Settings_LangManagement_Module_Model::setAsDefault() method ...');

    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\Language' in method 'getModFromLang'.
    Open

                            $modules[$name] = \App\Language::translate($name, $name);

    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 'setAsDefault'.
    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 'createCustomLangDirectory'.
    Open

                    \App\Log::warning("No permissions to create directories: $loc");

    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\Cache' in method 'delete'.
    Open

            \App\Cache::clear();

    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\Cache' in method 'add'.
    Open

            \App\Cache::clear();

    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\Json' in method 'loadCustomLanguageFile'.
    Open

                    $response = \App\Json::decode(file_get_contents($custom), 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

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

                        } else {
                            $modules[$name] = \App\Language::translate($name, $name);
                        }

    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 'add'.
    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\Cache' in method 'setAsDefault'.
    Open

            \App\Cache::clear();

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

            $folders = ['custom', 'languages', $params['lang']];

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

                    ->where(['isdefault' => 1])

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

            $folders = ['custom', 'languages', $params['lang']];

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

                return ['success' => false, 'data' => 'LBL_LangExist'];

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

            $db->createCommand()->insert('vtiger_language', [

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

            $destiny = 'languages/' . $params['prefix'] . '/';

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

            if (isset(App\Language::getAll(false)[$params['prefix']])) {

    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 local variables such as '$name'.
    Open

                foreach ($gropu as $mode => $name) {

    UnusedLocalVariable

    Since: 0.2

    Detects when a local variable is declared and/or assigned, but not used.

    Example

    class Foo {
        public function doSomething()
        {
            $i = 5; // Unused
        }
    }

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

    Argument 1 (input) is float|int but \array_keys() takes array
    Open

            foreach (array_keys($keysJs) as $key) {

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

                $status = (bool) $db->createCommand()->update('vtiger_language', ['isdefault' => 1], ['prefix' => $prefix])->execute();

    Call to undeclared method \RecursiveIteratorIterator::getSubPath
    Open

                            $settings["{$iterator->getSubPath()}__{$name}"] = \App\Language::translate($name, "{$iterator->getSubPath()}.$name");

    Call to method languageTag from undeclared class \App\Validator (Did you mean class \Tests\App\Validator)
    Open

            if (!\App\Validator::languageTag($params['prefix'])) {

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

            \App\Log::trace('Exiting Settings_LangManagement_Module_Model::setAsDefault() method ...');

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

                    \App\Log::warning("No permissions to create directories: $loc");

    Argument 1 (input) is float|int but \array_keys() takes array
    Open

            foreach (array_keys($keysPhp) as $key) {

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

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

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

            $db->createCommand()->insert('vtiger_language', [

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

                    $db->createCommand()->update('vtiger_language', ['isdefault' => 0], ['isdefault' => 1])->execute();

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

            \App\Log::trace('Entering Settings_LangManagement_Module_Model::setAsDefault(' . $prefix . ') method ...');

    Argument 2 (objectDecodeType) is true but \App\Json::decode() takes int defined at /code/app/Json.php:37
    Open

                    $response = \App\Json::decode(file_get_contents($custom), true);

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

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

    Call to undeclared method \RecursiveIteratorIterator::getSubPath
    Open

                        if ($iterator->getSubPath()) {

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

    class Settings_LangManagement_Module_Model extends Settings_Vtiger_Module_Model

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

            $fd = opendir($dir);

    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

    The class Settings_LangManagement_Module_Model is not named in CamelCase.
    Open

    class Settings_LangManagement_Module_Model extends Settings_Vtiger_Module_Model
    {
        const URL_SEPARATOR = '__';
    
        /**

    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 $b. Configured minimum length is 3.
    Open

        public static function parseData($a, $b)

    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 $a. Configured minimum length is 3.
    Open

        public static function parseData($a, $b)

    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 $i. Configured minimum length is 3.
    Open

            $i = 0;

    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

                $folders[] = 'Settings';

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

                }

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

        }

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

         * Function gets translations.

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

         * @param string   $moduleName

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

            foreach ($langs as $lang) {

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

                    $langTab[$lang] = $langData;

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

            return ['php' => $respPhp, 'js' => $respJs, 'langs' => $langs];

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

        {

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

                $custom = ROOT_DIRECTORY . DIRECTORY_SEPARATOR . 'custom' . DIRECTORY_SEPARATOR . 'languages' . DIRECTORY_SEPARATOR . $language . DIRECTORY_SEPARATOR . $moduleName . '.' . \App\Language::FORMAT;

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

        public static function createCustomLangDirectory($params)

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

            $mod = explode(self::URL_SEPARATOR, $params['mod']);

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

                    $respJs[$key][$language] = isset($langTab[$language]['js'][$key]) ? \App\Purifier::encodeHtml($langTab[$language]['js'][$key]) : null;

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

         * @param array  $languages

    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

                    $keysJs += $langData['js'] ?? [];

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

            foreach (array_keys($keysJs) as $key) {

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

         * @param array $params

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

        public function loadLangTranslation($langs, $moduleName)

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

            $keysPhp = $keysJs = $langTab = $respPhp = $respJs = [];

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

            $moduleName = str_replace(self::URL_SEPARATOR, DIRECTORY_SEPARATOR, $moduleName);

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

                foreach ($langs as $language) {

    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

            $loc = '';

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

            }

    Line exceeds 120 characters; contains 150 characters
    Open

                    $respJs[$key][$language] = isset($langTab[$language]['js'][$key]) ? \App\Purifier::encodeHtml($langTab[$language]['js'][$key]) : null;

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

                if (file_exists($custom)) {

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

         *

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

                    \App\Log::warning("No permissions to create directories: $loc");

    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

            foreach ($languages as $language) {

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

                $loc .= DIRECTORY_SEPARATOR . $name;

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

                foreach ($langs as $language) {

    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 = [];

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

                    $response = \App\Json::decode(file_get_contents($custom), 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

            if (\count($mod) > 1) {

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

        const URL_SEPARATOR = '__';

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

         * @throws \App\Exceptions\AppException

    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

                if ($langData) {

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

            }

    Line exceeds 120 characters; contains 153 characters
    Open

                    $respPhp[$key][$language] = isset($langTab[$language]['php'][$key]) ? \App\Purifier::encodeHtml($langTab[$language]['php'][$key]) : null;

    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

        public function loadCustomLanguageFile(array $languages, string $moduleName)

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

                    if ($response) {

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

    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 ($folders as $name) {

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

                    throw new \App\Exceptions\AppException('No permissions to create directories');

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

         * @param string[] $langs

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

            foreach (array_keys($keysPhp) as $key) {

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

         * Load custom languages data.

    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

            if (!\is_array($langs)) {

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

                $langData = \App\Language::getFromFile($moduleName, $lang);

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

        /**

    Line exceeds 120 characters; contains 206 characters
    Open

                $custom = ROOT_DIRECTORY . DIRECTORY_SEPARATOR . 'custom' . DIRECTORY_SEPARATOR . 'languages' . DIRECTORY_SEPARATOR . $language . DIRECTORY_SEPARATOR . $moduleName . '.' . \App\Language::FORMAT;

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

         * Function creates directory structure.

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

            $folders = ['custom', 'languages', $params['lang']];

    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

    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 (!file_exists(ROOT_DIRECTORY . $loc) && !mkdir(ROOT_DIRECTORY . $loc)) {

    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

                    $keysPhp += $langData['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

                    $respPhp[$key][$language] = isset($langTab[$language]['php'][$key]) ? \App\Purifier::encodeHtml($langTab[$language]['php'][$key]) : null;

    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 = array_replace_recursive($result, $response);

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

                $langs = [$langs];

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

            $moduleName = str_replace(self::URL_SEPARATOR, DIRECTORY_SEPARATOR, $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

        }

    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

            vtlib\Functions::recurseCopy('languages/' . \App\Language::DEFAULT_LANG, $destiny);

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

        public static function delete($prefix)

    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

         *

    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 (isset(App\Language::getAll(false)[$params['prefix']])) {

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

            $dir = 'languages/' . $prefix;

    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 array $params

    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

        /**

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

         * @return bool

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

                    self::deleteDir($dir . '/' . $file);

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

        /**

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

         * Function to set language as default.

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

            \App\Log::trace('Exiting Settings_LangManagement_Module_Model::setAsDefault() method ...');

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

                'custom' . DIRECTORY_SEPARATOR . 'languages' . DIRECTORY_SEPARATOR . $lang

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

            \App\Cache::clear();

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

                $resp = 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

         *

    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

            $modules = [];

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

                        $name = $object->getBasename(".$format");

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

            return ['mods' => $modules, 'settings' => $settings];

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

            }

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

                'prefix' => $params['prefix'],

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

            if (file_exists($dir)) {

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

         *

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

            $fd = opendir($dir);

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

                    unlink("$dir/$file");

    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

                    continue;

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

         * Function added new language.

    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 ['success' => true, 'data' => 'LBL_AddDataOK'];

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

         * Parse data.

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

            $resp = false;

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

                if (is_dir($dir . '/' . $file)) {

    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

            $lang = empty($lang) ? \App\Language::getLanguage() : $lang;

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

                if (!is_dir($dir)) {

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

                return ['success' => false, 'data' => 'LBL_LangExist'];

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

            \App\Cache::clear();

    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 string $b

    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 (!$fd) {

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

        {

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

            rmdir($dir);

    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

            $status = false;

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

                    $db->createCommand()->update('vtiger_language', ['isdefault' => 0], ['isdefault' => 1])->execute();

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

                $configFile = new \App\ConfigFile('main');

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

                $configFile->create();

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

                    $prefixOld = $dataReader->readColumn(0);

    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

                'languages' . DIRECTORY_SEPARATOR . $lang,

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

            ];

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

                            $modules[$name] = \App\Language::translate($name, $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

        public static function add($params)

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

            $db->createCommand()->insert('vtiger_language', [

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

                ->delete('vtiger_language', ['prefix' => $prefix])

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

         * @return bool

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

                    ->where(['isdefault' => 1])

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

                            $settings["{$iterator->getSubPath()}__{$name}"] = \App\Language::translate($name, "{$iterator->getSubPath()}.$name");

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

                                $differences[$lang][] = $key;

    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

                mkdir($destiny);

    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

            while (false !== ($file = readdir($fd))) {

    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

        public static function setAsDefault($prefix)

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

            \App\Log::trace('Entering Settings_LangManagement_Module_Model::setAsDefault(' . $prefix . ') method ...');

    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

         * Get modules from language.

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

                }

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

                $status = (bool) $db->createCommand()->update('vtiger_language', ['isdefault' => 1], ['prefix' => $prefix])->execute();

    Line exceeds 120 characters; contains 131 characters
    Open

                $status = (bool) $db->createCommand()->update('vtiger_language', ['isdefault' => 1], ['prefix' => $prefix])->execute();

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

            \App\Cache::clear();

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

         * @param string $lang

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

            return ['success' => $status, 'prefixOld' => $prefixOld ?? ''];

    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 ($iterator->getSubPath()) {

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

            foreach ($data as $id => $dataLang) {

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

                foreach ($dataLang as $key => $langs) {

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

                    }

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

                                $differences[$id][$key][$lang] = $value;

    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

                'name' => $params['label'],

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

         * Dedlete dir.

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

         */

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

                $configFile->set('default_language', $prefix);

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

            foreach ($filesName as $gropu) {

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

                            empty($langs[$langBase]) ?: ++$i;

    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 getModFromLang($lang)

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

            $settings = [];

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

            $dirs = [

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

            if (!is_dir($destiny)) {

    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

                'lastupdated' => date('Y-m-d H:i:s')

    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

                self::deleteDir($dir);

    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

         * @param string $a

    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(['prefix'])

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

                foreach ($gropu as $mode => $name) {

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

            $format = \App\Language::FORMAT;

    Line exceeds 120 characters; contains 153 characters
    Open

                foreach ($iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir), RecursiveIteratorIterator::SELF_FIRST) as $object) {

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

                    if ($object->getExtension() === $format) {

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

         * @param string $dir

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

         */

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

            closedir($fd);

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

         * @param string $prefix

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

            $filesName = $this->getModFromLang($langBase);

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

            }

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

                        $data[$mode] = $this->getStats($this->loadLangTranslation($langs, $mode), $langBase, $byModule);

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

                        if (!empty($langs[$langBase]) && ($value == $langs[$langBase] || empty($value))) {

    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 ($dirs as $dir) {

    Line exceeds 120 characters; contains 141 characters
    Open

                            $settings["{$iterator->getSubPath()}__{$name}"] = \App\Language::translate($name, "{$iterator->getSubPath()}.$name");

    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

                ->execute();

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

            if ('' != $b && false !== stristr($b, $a)) {

    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 ('.' === $file || '..' === $file) {

    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

                    ->from('vtiger_language')

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

                if (1 === $dataReader->count()) {

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

            }

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

            $langs = (array) $langs;

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

                $langs[] = $langBase;

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

            $differences = [];

    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 ($iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir), RecursiveIteratorIterator::SELF_FIRST) as $object) {

    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

            if (!\App\Validator::languageTag($params['prefix'])) {

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

                'name' => $params['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

        public static function deleteDir($dir)

    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

            $i = 0;

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

                if (!\in_array($id, ['php', 'js'])) {

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

            if (false === $byModule) {

    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 ['success' => false, 'data' => 'LBL_NOT_CORRECT_LANGUAGE_TAG'];

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

            $destiny = 'languages/' . $params['prefix'] . '/';

    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 parseData($a, $b)

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

            return $resp;

    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\Language::getLangInfo($prefix)) {

    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 ($lang == $langBase) {

    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

                array_unshift($differences, $i);

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

            $data = [];

    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

                    continue;

    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

        }

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

                                $differences[$id][$key][$langBase] = $langs[$langBase];

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

            return $differences;

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

            if (!\in_array($langBase, $langs)) {

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

                    if (false === $byModule || $byModule === $mode) {

    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 ($langs as $lang => $value) {

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

                            if (false !== $byModule) {

    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 getStatsData($langBase, $langs, $byModule = 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

            return $data;

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

        public function getStats($data, $langBase, $byModule)

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

                            } else {

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

    class Settings_LangManagement_Module_Model extends Settings_Vtiger_Module_Model

    There are no issues that match your filters.

    Category
    Status