YetiForceCompany/YetiForceCRM

View on GitHub
vtlib/Vtiger/LanguageExport.php

Summary

Maintainability
A
2 hrs
Test Coverage
D
65%

Method register has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function register(string $prefix, string $name = '', ?bool $isDefault = false, bool $isActive = true, int $progress = 0)
    {
        $dbCommand = \App\Db::getInstance()->createCommand();
        $prefix = trim($prefix);
        if ($langInfo = \App\Language::getLangInfo($prefix)) {
Severity: Minor
Found in vtlib/Vtiger/LanguageExport.php - About 1 hr to fix

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

        public function exportLanguage($languageCode, $todir = '', $zipfilename = '', $directDownload = false)
        {
            $this->__initExport($languageCode);
            // Call language export function
            $this->generateLangMainfest($languageCode);
    Severity: Minor
    Found in vtlib/Vtiger/LanguageExport.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

    Method register has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        public static function register(string $prefix, string $name = '', ?bool $isDefault = false, bool $isActive = true, int $progress = 0)
    Severity: Minor
    Found in vtlib/Vtiger/LanguageExport.php - About 35 mins to fix

      Missing class import via use statement (line '168', column '17').
      Open

              $query = (new \App\Db\Query())->from(self::TABLENAME)->select(['prefix', 'name']);
      Severity: Minor
      Found in vtlib/Vtiger/LanguageExport.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 register has a boolean flag argument $isActive, which is a certain sign of a Single Responsibility Principle violation.
      Open

          public static function register(string $prefix, string $name = '', ?bool $isDefault = false, bool $isActive = true, int $progress = 0)
      Severity: Minor
      Found in vtlib/Vtiger/LanguageExport.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

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

          public function exportLanguage($languageCode, $todir = '', $zipfilename = '', $directDownload = false)
      Severity: Minor
      Found in vtlib/Vtiger/LanguageExport.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

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

          public static function register(string $prefix, string $name = '', ?bool $isDefault = false, bool $isActive = true, int $progress = 0)
      Severity: Minor
      Found in vtlib/Vtiger/LanguageExport.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

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

          public static function getAll($includeInActive = false)
      Severity: Minor
      Found in vtlib/Vtiger/LanguageExport.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

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

              \App\Log::trace("Registering Language $name [$prefix] ... DONE", __METHOD__);
      Severity: Minor
      Found in vtlib/Vtiger/LanguageExport.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\Zip' in method 'exportLanguage'.
      Open

              $zip = \App\Zip::createFile($zipfilename);
      Severity: Minor
      Found in vtlib/Vtiger/LanguageExport.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 assigning values to variables in if clauses and the like (line '115', column '7').
      Open

          public static function register(string $prefix, string $name = '', ?bool $isDefault = false, bool $isActive = true, int $progress = 0)
          {
              $dbCommand = \App\Db::getInstance()->createCommand();
              $prefix = trim($prefix);
              if ($langInfo = \App\Language::getLangInfo($prefix)) {
      Severity: Minor
      Found in vtlib/Vtiger/LanguageExport.php by phpmd

      IfStatementAssignment

      Since: 2.7.0

      Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

      Example

      class Foo
      {
          public function bar($flag)
          {
              if ($foo = 'bar') { // possible typo
                  // ...
              }
              if ($baz = 0) { // always false
                  // ...
              }
          }
      }

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

      Avoid using static access to class '\App\Cache' in method 'register'.
      Open

              \App\Cache::clear();
      Severity: Minor
      Found in vtlib/Vtiger/LanguageExport.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\Language' in method 'generateLangMainfest'.
      Open

              $langInfo = \App\Language::getLangInfo($prefix);
      Severity: Minor
      Found in vtlib/Vtiger/LanguageExport.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\Purifier' in method 'generateLangMainfest'.
      Open

              $this->outputNode(\App\Purifier::decodeHtml($langInfo['name']), 'name');
      Severity: Minor
      Found in vtlib/Vtiger/LanguageExport.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\Log' in method 'deregister'.
      Open

              \App\Log::trace("Deregistering Language $prefix ... DONE", __METHOD__);
      Severity: Minor
      Found in vtlib/Vtiger/LanguageExport.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 'vtlib\Utils' in method '__initExport'.
      Open

              Utils::checkFileAccessForInclusion("languages/$languageCode/_Base.json");
      Severity: Minor
      Found in vtlib/Vtiger/LanguageExport.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\Language' in method 'register'.
      Open

              if ($langInfo = \App\Language::getLangInfo($prefix)) {
      Severity: Minor
      Found in vtlib/Vtiger/LanguageExport.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\Config' in method 'generateLangMainfest'.
      Open

              $this->outputNode(\App\Config::main('default_charset'), 'encoding');
      Severity: Minor
      Found in vtlib/Vtiger/LanguageExport.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 exportLanguage uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

              } else {
                  $zip->close();
                  if ($todir) {
                      copy($zipfilename, $todir);
                  }
      Severity: Minor
      Found in vtlib/Vtiger/LanguageExport.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

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

              } else {
                  $dbCommand->insert(
                      static::TABLENAME,
                      [
                          'name' => $name,
      Severity: Minor
      Found in vtlib/Vtiger/LanguageExport.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 '\App\Version' in method 'generateLangMainfest'.
      Open

              $this->outputNode(\App\Version::get(), 'vtiger_version');
      Severity: Minor
      Found in vtlib/Vtiger/LanguageExport.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 "isdefault" 3 times.
      Open

                          'isdefault' => (int) (null === $isDefault ? $langInfo['isdefault'] : $isDefault),
      Severity: Critical
      Found in vtlib/Vtiger/LanguageExport.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 "prefix" 6 times.
      Open

              $this->outputNode($prefix, 'prefix');
      Severity: Critical
      Found in vtlib/Vtiger/LanguageExport.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 "active" 3 times.
      Open

                          'active' => (int) $isActive,
      Severity: Critical
      Found in vtlib/Vtiger/LanguageExport.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 '$moduleInstance'.
      Open

          public function __initExport($languageCode, $moduleInstance = null)
      Severity: Minor
      Found in vtlib/Vtiger/LanguageExport.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

      @throws type of register has undeclared type \yii\db\Exception (Did you mean class \Exception)
      Open

          public static function register(string $prefix, string $name = '', ?bool $isDefault = false, bool $isActive = true, int $progress = 0)
      Severity: Minor
      Found in vtlib/Vtiger/LanguageExport.php by phan

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

              \App\Db::getInstance()->createCommand()->delete(self::TABLENAME, ['prefix' => $prefix])->execute();
      Severity: Critical
      Found in vtlib/Vtiger/LanguageExport.php by phan

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

              \App\Log::trace("Registering Language $name [$prefix] ... DONE", __METHOD__);
      Severity: Critical
      Found in vtlib/Vtiger/LanguageExport.php by phan

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

              $dbCommand = \App\Db::getInstance()->createCommand();
      Severity: Critical
      Found in vtlib/Vtiger/LanguageExport.php by phan

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

              \App\Log::trace("Deregistering Language $prefix ... DONE", __METHOD__);
      Severity: Critical
      Found in vtlib/Vtiger/LanguageExport.php by phan

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

              $query = (new \App\Db\Query())->from(self::TABLENAME)->select(['prefix', 'name']);
      Severity: Critical
      Found in vtlib/Vtiger/LanguageExport.php by phan

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

           * @param mixed|null $moduleInstance

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

          }

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

              $this->__finishExport();

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

              // Add manifest file

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

              // Copy module directory

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

              $this->outputNode('language', 'type');

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

           * @param string    $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

          }

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

           * Export Language Handler.

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

           */

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

                          'isdefault' => (int) (null === $isDefault ? $langInfo['isdefault'] : $isDefault),

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

                      ['prefix' => $prefix]

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

                          'progress' => $progress,

      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;

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

              \App\Db::getInstance()->createCommand()->delete(self::TABLENAME, ['prefix' => $prefix])->execute();

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

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

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

                  $languages[$row['prefix']] = $row['name'];

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

              return $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

              // Call language export function

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

                      $zip->addDirectory($path);

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

                  }

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

              $this->outputNode(\App\Version::get(), 'vtiger_version');

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

           * @throws \yii\db\Exception

      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' => $prefix,

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

              // Security check to ensure file is withing the web folder.

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

              // Export as Zip

      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

              $this->outputNode($prefix, 'prefix');

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

              \App\Log::trace("Registering Language $name [$prefix] ... DONE", __METHOD__);

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

           * @param string $prefix Language prefix like (de-De) etc

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

              if (!$includeInActive) {

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

              $dataReader = $query->createCommand()->query();

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

           *

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

              if ('' === $zipfilename) {

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

                  $path = $dir . \DIRECTORY_SEPARATOR . $languageCode;

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

                  if (file_exists($path)) {

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

                      copy($zipfilename, $todir);

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

              $this->openNode('module');

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

              $this->outputNode('YetiForce S.A.', 'author');

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

              $this->closeNode('dependencies');

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

              $dbCommand = \App\Db::getInstance()->createCommand();

      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 __initExport($languageCode, $moduleInstance = null)

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

              $this->__write("<?xml version='1.0'?>\n");

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

           * @param string $languageCode   Module Instance of module

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

              foreach (['languages', 'custom' . \DIRECTORY_SEPARATOR . 'languages'] as $dir) {

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

                  $zip->close();

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

              $this->__cleanupExport();

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

              $this->outputNode('language', 'type');

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

              $this->outputNode(\App\Config::main('default_charset'), 'encoding');

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

           * @param int       $progress

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

              // We will not allow deregistering core language

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

          public static function getAll($includeInActive = 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

           * @param string $todir          Path Output directory path

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

              }

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

          private function generateLangMainfest($prefix)

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

              // Export dependency information

      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

          {

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

           * Export Module as a zip 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

              if ($directDownload) {

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

          }

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

              $this->outputNode(\App\Purifier::decodeHtml($langInfo['name']), 'name');

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

              $this->outputNode('YetiForce Public License 6.5 (yetiforce.com)', 'license');

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

                  $dbCommand->update(

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

                  )->execute();

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

          /**

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

          }

      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 exportLanguage($languageCode, $todir = '', $zipfilename = '', $directDownload = false)

      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

          /**

      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    $prefix

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

                      static::TABLENAME,

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

                          'name' => $name,

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

           * @param mixed      $languageCode

      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

              $zipfilename = "$this->_export_tmpdir/$zipfilename";

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

           * @param bool      $isActive

      Line exceeds 120 characters; contains 138 characters
      Open

          public static function register(string $prefix, string $name = '', ?bool $isDefault = false, bool $isActive = true, int $progress = 0)

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

                          'isdefault' => (int) $isDefault,

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

           */

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

           * Initialize Export.

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

                  $zipfilename = "$languageCode-" . date('YmdHis') . '.zip';

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

              }

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

                  $zip->download($languageCode);

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

           * Register language pack information.

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

          public static function register(string $prefix, string $name = '', ?bool $isDefault = false, bool $isActive = true, int $progress = 0)

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

                          'progress' => $progress,

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

                      ],

      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

              $prefix = trim($prefix);

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

              \App\Log::trace("Deregistering Language $prefix ... DONE", __METHOD__);

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

           * @param bool $includeInActive true to include in-active languages also, false (default)

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

              Utils::checkFileAccessForInclusion("languages/$languageCode/_Base.json");

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

           * @param bool   $directDownload True for sending the output as download

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

              $this->__initExport($languageCode);

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

              $zip = \App\Zip::createFile($zipfilename);

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

              $langInfo = \App\Language::getLangInfo($prefix);

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

                          'active' => (int) $isActive,

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

      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

              $this->openNode('dependencies');

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

           * @param bool|null $isDefault

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

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

                      static::TABLENAME,

      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 deregister($prefix)

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

                  $query->where(['active' => 1]);

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

          const TABLENAME = 'vtiger_language';

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

              $this->_export_modulexml_file = fopen($this->__getManifestFilePath(), 'w');

      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

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

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

                  $dbCommand->insert(

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

                          'active' => (int) $isActive,

      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\Cache::clear();

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

           * Get all the language information.

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

              $this->generateLangMainfest($languageCode);

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

              $zip->addFile($this->__getManifestFilePath(), 'manifest.xml');

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

          /**

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

              $this->closeNode('module');

      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 = trim($prefix);

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

                          'name' => $name,

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

           * De-Register language pack information.

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

              $query = (new \App\Db\Query())->from(self::TABLENAME)->select(['prefix', 'name']);

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

              $languages = [];

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

           * @param string $zipfilename

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

          {

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

                  )->execute();

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

           *

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

              if (strtolower($prefix) === strtolower(\App\Language::DEFAULT_LANG)) {

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

              asort($languages);

      The method __initExport is not named in camelCase.
      Open

          public function __initExport($languageCode, $moduleInstance = null)
          {
              // Security check to ensure file is withing the web folder.
              Utils::checkFileAccessForInclusion("languages/$languageCode/_Base.json");
              $this->_export_modulexml_file = fopen($this->__getManifestFilePath(), 'w');
      Severity: Minor
      Found in vtlib/Vtiger/LanguageExport.php by phpmd

      CamelCaseMethodName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name methods.

      Example

      class ClassName {
          public function get_name() {
          }
      }

      Source

      There are no issues that match your filters.

      Category
      Status