YetiForceCompany/YetiForceCRM

View on GitHub
modules/Settings/TreesManager/models/Record.php

Summary

Maintainability
D
3 days
Test Coverage
F
27%

File Record.php has 417 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 * Settings TreesManager record model class.
 *
Severity: Minor
Found in modules/Settings/TreesManager/models/Record.php - About 6 hrs to fix

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

    class Settings_TreesManager_Record_Model extends Settings_Vtiger_Record_Model
    {
        /**
         * Function to get the Id.
         *

    Settings_TreesManager_Record_Model has 25 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Settings_TreesManager_Record_Model extends Settings_Vtiger_Record_Model
    {
        /**
         * Function to get the Id.
         *
    Severity: Minor
    Found in modules/Settings/TreesManager/models/Record.php - About 2 hrs to fix

      Method getFieldInstanceByName has 61 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function getFieldInstanceByName(string $name)
          {
              $params = [];
              $qualifiedModuleName = 'Settings:TreesManager';
              switch ($name) {
      Severity: Major
      Found in modules/Settings/TreesManager/models/Record.php - About 2 hrs to fix

        Method getTree has 49 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getTree($category = false, $treeValue = false)
            {
                $tree = [];
                $templateId = $this->getId();
                if (empty($templateId)) {
        Severity: Minor
        Found in modules/Settings/TreesManager/models/Record.php - About 1 hr to fix

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

              public function getTree($category = false, $treeValue = false)
              {
                  $tree = [];
                  $templateId = $this->getId();
                  if (empty($templateId)) {
          Severity: Minor
          Found in modules/Settings/TreesManager/models/Record.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 parseTreeDataForSave has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              public function parseTreeDataForSave(array $tree): array
              {
                  $values = [];
                  foreach ($tree as $branch) {
                      $value = [];
          Severity: Minor
          Found in modules/Settings/TreesManager/models/Record.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 replaceValue has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              public function replaceValue($tree, $templateId)
              {
                  $db = App\Db::getInstance();
                  $modules = $this->get('share');
                  $modules[] = $this->get('tabid');
          Severity: Minor
          Found in modules/Settings/TreesManager/models/Record.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 parseTreeDataForSave has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function parseTreeDataForSave(array $tree): array
              {
                  $values = [];
                  foreach ($tree as $branch) {
                      $value = [];
          Severity: Minor
          Found in modules/Settings/TreesManager/models/Record.php - About 1 hr to fix

            Method replaceValue has 26 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function replaceValue($tree, $templateId)
                {
                    $db = App\Db::getInstance();
                    $modules = $this->get('share');
                    $modules[] = $this->get('tabid');
            Severity: Minor
            Found in modules/Settings/TreesManager/models/Record.php - About 1 hr to fix

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

                  public function getFieldInstanceByName(string $name)
                  {
                      $params = [];
                      $qualifiedModuleName = 'Settings:TreesManager';
                      switch ($name) {
              Severity: Minor
              Found in modules/Settings/TreesManager/models/Record.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 save has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function save()
                  {
                      $db = App\Db::getInstance();
                      $templateId = $this->getId();
                      $share = static::getShareFromArray($this->get('share'));
              Severity: Minor
              Found in modules/Settings/TreesManager/models/Record.php - About 35 mins to fix

              Cognitive Complexity

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

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

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

              Further reading

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

                  public static function getChildren(string $fieldValue, string $fieldName, Vtiger_Module_Model $moduleModel)
                  {
                      $templateId = (new App\Db\Query())->select(['fieldparams'])
                          ->from('vtiger_field')
                          ->where(['tabid' => $moduleModel->getId(), 'columnname' => $fieldName, 'presence' => [0, 2]])
              Severity: Minor
              Found in modules/Settings/TreesManager/models/Record.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 parseTreeDataForSave() has an NPath complexity of 225. The configured NPath complexity threshold is 200.
              Open

                  public function parseTreeDataForSave(array $tree): array
                  {
                      $values = [];
                      foreach ($tree as $branch) {
                          $value = [];

              NPathComplexity

              Since: 0.1

              The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

              Example

              class Foo {
                  function bar() {
                      // lots of complicated code
                  }
              }

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

              The method getTree() has an NPath complexity of 2056. The configured NPath complexity threshold is 200.
              Open

                  public function getTree($category = false, $treeValue = false)
                  {
                      $tree = [];
                      $templateId = $this->getId();
                      if (empty($templateId)) {

              NPathComplexity

              Since: 0.1

              The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

              Example

              class Foo {
                  function bar() {
                      // lots of complicated code
                  }
              }

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

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

                  public function getTree($category = false, $treeValue = false)
                  {
                      $tree = [];
                      $templateId = $this->getId();
                      if (empty($templateId)) {

              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 parseTreeDataForSave() has a Cyclomatic Complexity of 13. The configured cyclomatic complexity threshold is 10.
              Open

                  public function parseTreeDataForSave(array $tree): array
                  {
                      $values = [];
                      foreach ($tree as $branch) {
                          $value = [];

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

                  public function parseTreeDataForSave(array $tree): array

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

                  public function getTree($category = false, $treeValue = false)

              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

              Class "Settings_TreesManager_Record_Model" has 25 methods, which is greater than 20 authorized. Split it into smaller classes.
              Open

              class Settings_TreesManager_Record_Model extends Settings_Vtiger_Record_Model

              A class that grows too much tends to aggregate too many responsibilities and inevitably becomes harder to understand and therefore to maintain. Above a specific threshold, it is strongly advised to refactor the class into smaller ones which focus on well defined topics.

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

              class Settings_TreesManager_Record_Model extends Settings_Vtiger_Record_Model
              {
                  /**
                   * Function to get the Id.
                   *

              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

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

                  public function getTree($category = false, $treeValue = 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 '282', column '22').
              Open

                      $dataReader = (new App\Db\Query())->select(['tablename', 'columnname', 'uitype'])

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

                      $dataReader = (new App\Db\Query())->from('vtiger_trees_templates_data')

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

                      $dataReader = (new App\Db\Query())->from('vtiger_trees_templates_data')

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

                      $row = (new \App\Db\Query())->from('vtiger_trees_templates')->where(['templateid' => $record])->one();

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

                          $query = (new \App\Db\Query())->from($tableName);

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

                      $templateId = (new App\Db\Query())->select(['fieldparams'])

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

                  public function getTree($category = false, $treeValue = 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

              Avoid using static access to class '\Vtiger_Field_Model' in method 'getFieldInstanceByName'.
              Open

                      return $params ? \Vtiger_Field_Model::init($qualifiedModuleName, $params, $name) : 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 '\App\Json' in method 'getTree'.
              Open

                              'state' => ($row['state']) ? \App\Json::decode($row['state']) : '',

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

                                  $params['picklistValues'][$moduleModel->getId()] = \App\Language::translate($moduleModel->getName(), $moduleModel->getName());

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

                              'selected' => \App\Validator::bool($branch['state']['selected']) ? $branch['state']['selected'] : false,

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

                          $icon = \App\Purifier::decodeHtml($branch['icon'] ?? '');

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

                      } else {
                          $db->createCommand()
                              ->update('vtiger_trees_templates', ['name' => $this->get('name'), 'tabid' => $this->get('tabid'), 'share' => $share], ['templateid' => $templateId])
                              ->execute();
                          $db->createCommand()->delete('vtiger_trees_templates_data', ['templateid' => $templateId])

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

                              'opened' => \App\Validator::bool($branch['state']['opened']) ? $branch['state']['opened'] : false,

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

                          } elseif ($icon && ('1' === $icon || !\App\Validator::fontIcon($icon))) {

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

              Avoid using static access to class 'Vtiger_Link_Model' in method 'getRecordLinks'.
              Open

                          $links[] = Vtiger_Link_Model::getInstanceFromValues($recordLink);

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

                          $value['text'] = \App\Purifier::decodeHtml($branch['text']);

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

                      \App\Cache::staticSave($cacheName, $key, clone $instance);

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

                          } else {
                              $defaultValue = $fieldModel->get('defaultvalue');
                              $fieldModel->set('fieldvalue', $defaultValue ?? '');
                          }

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

                                  'text' => \App\Language::translate($row['name'], $module, null, false),

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

                          $module = App\Module::getModuleName($module);

              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 'save'.
              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

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

                          } else {
                              foreach ($tree as $treeRow) {
                                  $params = [];
                                  foreach ($treeRow['old'] as $new) {
                                      $params[] = 'T' . $new;

              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 'delete'.
              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 'clearCache'.
              Open

                      \App\Cache::delete('TreeValuesById', $this->getId());

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

                              $icon = \App\Purifier::purifyByType($icon, \App\Purifier::PATH);

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

              Avoid using static access to class 'Settings_Vtiger_Module_Model' in method 'getCleanInstance'.
              Open

                      $moduleInstance = Settings_Vtiger_Module_Model::getInstance('Settings:TreesManager');

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

                              'loaded' => \App\Validator::bool($branch['state']['loaded']) ? $branch['state']['loaded'] : false,

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

                              $value = \App\Language::translate($moduleName, $moduleName);

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

                          'state' => $tree['state'] ? \App\Json::encode($tree['state']) : '',

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

                              $value = \App\Language::translate($this->get($name), $this->getModule()->getName(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

              Avoid using static access to class '\App\Module' in method 'getDisplayValue'.
              Open

                              $moduleName = \App\Module::getModuleName($this->get($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

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

                          } else {
                              $val = [];
                          }

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

                      if (\App\Cache::staticHas($cacheName, $key)) {

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

                          return clone \App\Cache::staticGet($cacheName, $key);

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

                                  $params['picklistValues'][$moduleModel->getId()] = \App\Language::translate($moduleModel->getName(), $moduleModel->getName());

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

                              'disabled' => \App\Validator::bool($branch['state']['disabled']) ? $branch['state']['disabled'] : false,

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

                              'text' => \App\Language::translate($row['name'], $module, null, false),

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

                      return $this->get('templateid');

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

                                  'purifyType' => \App\Purifier::TEXT,

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

                          'parentTree' => $parentTree,

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

                      if ('share' === $key) {

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

                      $dataReader = (new App\Db\Query())->select(['tablename', 'columnname', 'uitype'])

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

                                  'picklistValues' => [],

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

                      App\Db::getInstance()->createCommand()->insert('vtiger_trees_templates_data', $params)->execute();

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

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

              Noncompliant Code Example

              With the default threshold of 3:

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

              Compliant Solution

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

              Exceptions

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

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

                      $dataReader = (new App\Db\Query())->select(['tablename', 'columnname', 'uitype'])

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

                                  'column' => $name,

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

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

              Noncompliant Code Example

              With the default threshold of 3:

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

              Compliant Solution

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

              Exceptions

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

              Define a constant instead of duplicating this literal "children" 5 times.
              Open

                      if (!empty($tree['children'])) {

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

                          'state' => $tree['state'] ? \App\Json::encode($tree['state']) : '',

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

                              'opened' => \App\Validator::bool($branch['state']['opened']) ? $branch['state']['opened'] : false,

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

                                  'maximumlength' => 255,

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

                              'disabled' => \App\Validator::bool($branch['state']['disabled']) ? $branch['state']['disabled'] : false,

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

                              ->insert('vtiger_trees_templates', ['name' => $this->get('name'), 'tabid' => $this->get('tabid'), 'share' => $share])

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

                                  'typeofdata' => 'V~M',

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

                              'selected' => \App\Validator::bool($branch['state']['selected']) ? $branch['state']['selected'] : false,

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

                              'loaded' => \App\Validator::bool($branch['state']['loaded']) ? $branch['state']['loaded'] : false,

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

                          'label' => $label,

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

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

              Noncompliant Code Example

              With the default threshold of 3:

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

              Compliant Solution

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

              Exceptions

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

              Define a constant instead of duplicating this literal "tabid" 11 times.
              Open

                      $module = $this->get('tabid');

              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.

              Reference to undeclared property \Settings_TreesManager_Record_Model->module
              Open

                      return $this->module;

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

                      $dataReader = (new App\Db\Query())->from('vtiger_trees_templates_data')

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

                      $row = (new \App\Db\Query())->from('vtiger_trees_templates')->where(['templateid' => $record])->one();

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

                      App\Db::getInstance()->createCommand()->insert('vtiger_trees_templates_data', $params)->execute();

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

                          $query = (new \App\Db\Query())->from($tableName);

              Saw an @param annotation for moduleMode, but it was not found in the param list of function getChildren(string $fieldValue, string $fieldName, \Vtiger_Module_Model $moduleModel) : string
              Open

                   * @param \Vtiger_Module_Model $moduleMode

              Default value for string $treeValue can't be false
              Open

                  public function getTree($category = false, $treeValue = false)

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

                      $dataReader = (new App\Db\Query())->select(['tablename', 'columnname', 'uitype'])

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

                                  $db->createCommand()

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

                      $templateId = (new App\Db\Query())->select(['fieldparams'])

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

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

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

                      $dataReader = (new App\Db\Query())->from('vtiger_trees_templates_data')

              Reference to undeclared property \Settings_TreesManager_Record_Model->module
              Open

                      $this->module = $moduleModel;

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

                          $db->createCommand()

              Saw unextractable annotation for comment '* @return <number> Role Id'</number>
              Open

                   * @return <Number> Role Id

              Default value for string $category can't be false
              Open

                  public function getTree($category = false, $treeValue = false)

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

                          $db->createCommand()

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

                          $db->createCommand()->delete('vtiger_trees_templates_data', ['templateid' => $templateId])

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

                      $db->createCommand()->delete('vtiger_trees_templates', ['templateid' => $templateId])->execute();

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

                  private function updateCategoryMultipicklist(array $tree, string $tableName, string $columnName)

              Return type of getCleanInstance() is undeclared type \self
              Open

                  public static function getCleanInstance()

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

                              'loaded' => \App\Validator::bool($branch['state']['loaded']) ? $branch['state']['loaded'] : false,

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

                          } elseif ($icon && ('1' === $icon || !\App\Validator::fontIcon($icon))) {

              Argument 2 (moduleName) is false but \App\Language::translate() takes string defined at /code/app/Language.php:161
              Open

                                  $params['picklistValues'][$moduleModel->getId()] = \App\Language::translate($moduleModel->getName(), $moduleModel->getName());

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

                              'selected' => \App\Validator::bool($branch['state']['selected']) ? $branch['state']['selected'] : false,

              Argument 2 (key) is int but \App\Cache::delete() takes string defined at /code/app/Cache.php:105
              Open

                      \App\Cache::delete('TreeValuesById', $this->getId());

              Argument 1 (key) is false but \App\Language::translate() takes string defined at /code/app/Language.php:161
              Open

                                  $params['picklistValues'][$moduleModel->getId()] = \App\Language::translate($moduleModel->getName(), $moduleModel->getName());

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

                              'opened' => \App\Validator::bool($branch['state']['opened']) ? $branch['state']['opened'] : false,

              Returning type null but getFieldInstanceByName() is declared to return \Vtiger_Field_Model
              Open

                      return $params ? \Vtiger_Field_Model::init($qualifiedModuleName, $params, $name) : null;

              Argument 1 (key) is false but \App\Language::translate() takes string defined at /code/app/Language.php:161
              Open

                                  $params['picklistValues'][$moduleModel->getId()] = \App\Language::translate($moduleModel->getName(), $moduleModel->getName());

              Saw possibly unextractable annotation for a fragment of comment '* @param array()|null $share': after array, did not see an element name (will guess based on comment order)
              Open

                   * @param array()|null $share

              Reference to undeclared property \Settings_TreesManager_Record_Model->module
              Open

                      $instance->module = $moduleInstance;

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

                              'disabled' => \App\Validator::bool($branch['state']['disabled']) ? $branch['state']['disabled'] : false,

              Saw a token Phan may have failed to parse after '* @param array()|null $share': after array, saw '('
              Open

                   * @param array()|null $share

              Argument 2 (moduleName) is false but \App\Language::translate() takes string defined at /code/app/Language.php:161
              Open

                                  $params['picklistValues'][$moduleModel->getId()] = \App\Language::translate($moduleModel->getName(), $moduleModel->getName());

              Similar blocks of code found in 4 locations. Consider refactoring.
              Open

                  public function getRecordLinks(): array
                  {
                      $links = [];
                      $recordLinks = [
                          [
              Severity: Major
              Found in modules/Settings/TreesManager/models/Record.php and 3 other locations - About 1 hr to fix
              modules/Settings/AutomaticAssignment/models/Record.php on lines 213..236
              modules/Settings/BusinessHours/models/Record.php on lines 242..265
              modules/Settings/Groups/models/Record.php on lines 420..443

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 117.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

              Similar blocks of code found in 2 locations. Consider refactoring.
              Open

                  public static function getCleanInstance()
                  {
                      $cacheName = __CLASS__;
                      $key = 'Clean';
                      if (\App\Cache::staticHas($cacheName, $key)) {
              Severity: Major
              Found in modules/Settings/TreesManager/models/Record.php and 1 other location - About 1 hr to fix
              modules/Settings/AutomaticAssignment/models/Record.php on lines 282..295

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 103.

              We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

              The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

              If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

              See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

              Refactorings

              Further Reading

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

              class Settings_TreesManager_Record_Model extends Settings_Vtiger_Record_Model

              The class Settings_TreesManager_Record_Model is not named in CamelCase.
              Open

              class Settings_TreesManager_Record_Model extends Settings_Vtiger_Record_Model
              {
                  /**
                   * Function to get the Id.
                   *

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

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

              ShortVariable

              Since: 0.2

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

              Example

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

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

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

                      $id = $tree['id'];

              ShortVariable

              Since: 0.2

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

              Example

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

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

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

                  /**

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

                              'linklabel' => 'LBL_EDIT',

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

                              'linkclass' => 'btn btn-sm btn-info',

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

                  public function insertData($tree, $depth, $parentTree)

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

                      $treeID = 'T' . $id;

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

                  public function getName()

              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->module = $moduleModel;

              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

                  /** {@inheritdoc} */

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

                              'linktype' => 'LISTVIEWRECORD',

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

                              'linkclass' => 'btn btn-sm btn-danger text-white',

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

                   * Function to get the Id.

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

                      return $this;

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

              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

                          'templateid' => $this->getId(),

              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

                      $id = $tree['id'];

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

                   * @return <Number> Role Id

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

                   * @return string

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

                   * @return Settings_TreesManager_Module_Model $moduleModel

              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 getRecordLinks(): 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

                              'linklabel' => 'LBL_DELETE',

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

                              'linkurl' => "javascript:Settings_Vtiger_List_Js.triggerDelete(event,'" . $this->getDeleteUrl() . "');",

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

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

                  public function setModule($moduleModel)

              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

                      $label = $tree['text'];

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

                          'parentTree' => $parentTree,

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

                  public function getId()

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

                   * Function to get the Role 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

                   * Function to get Detail view url.

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

                              'linktype' => 'LISTVIEWRECORD',

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

              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 to set module instance to this record instance.

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

                   * @return string Url

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

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

                  }

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

                          'tree' => $treeID,

              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 to get the Edit View Url for the Role.

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

                      return 'index.php?module=TreesManager&parent=Settings&view=Edit&record=' . $this->getId();

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

                      return '?module=TreesManager&parent=Settings&action=Delete&record=' . $this->getId();

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

                   * @return string Url

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

                              'linkurl' => $this->getEditViewUrl(),

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

                              'linkicon' => 'fas fa-trash-alt',

              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 Settings_Vtiger_Module_Model $moduleModel

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

                   * Function to get List view url.

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

              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 'index.php?module=TreesManager&parent=Settings&view=Edit&record=' . $this->getId();

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

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

                      $recordLinks = [

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

                      return $this->get('templateid');

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

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

                   * @return string

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

                  {

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

                      if ('' != $parentTree) {

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

                      $params = [

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

                      return $this->get('rolename');

              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 string

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

                  public function getDetailViewUrl()

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

                      return 'index.php?module=TreesManager&parent=Settings&view=List';

              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 ($recordLinks as $recordLink) {

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

                   * Function to save the role.

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

                      $parentTree = $parentTree . $treeID;

              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 get module of this record instance.

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

                   *

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

                  /**

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

                   * Function to get the Delete Action Url for the current role.

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

                  public function getDeleteUrl()

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

              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

                          $links[] = Vtiger_Link_Model::getInstanceFromValues($recordLink);

              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 int    $depth

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

                          $parentTree = $parentTree . '::';

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

                          'name' => $label,

              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

                      $links = [];

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

                              'linkicon' => 'yfi yfi-full-editing-view',

              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 ($tree['children'] as $treeChild) {

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

                              $icon = 'public_html/' . $icon;

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

                              $parameters['type'] = $category;

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

                      $this->set('lastId', $lastId);

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

                  public function get($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

                              $this->insertData($tree, 0, '');

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

                      $this->clearCache();

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

                  {

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

                      App\Db::getInstance()->createCommand()->insert('vtiger_trees_templates_data', $params)->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

                          $pieces = explode('::', $parentTree);

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

                          $icon = $row['icon'] ?: false;

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

                                  'text' => \App\Language::translate($row['name'], $module, null, false),

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

                      return $val;

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

                          $db->createCommand()

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

                   * @param int   $templateId

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

                   *

              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

                              'text' => \App\Language::translate($row['name'], $module, null, false),

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

                      $val = parent::get($key);

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

                      if ($this->get('replace')) {

              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

                      $dataReader = (new App\Db\Query())->select(['tablename', 'columnname', 'uitype'])

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

                          $columnName = $row['columnname'];

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

                      if (!empty($tree['children'])) {

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

                          'state' => $tree['state'] ? \App\Json::encode($tree['state']) : '',

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

                      if (empty($templateId)) {

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

                   *

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

                          $module = App\Module::getModuleName($module);

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

                              $lastId = $treeID;

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

                      if (is_numeric($module)) {

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

                          $db->createCommand()

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

                          $parameters = [

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

                   * Function to replaces value in module records.

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

                   * @param array $tree

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

                  /**

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

                   * Get.

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

                              foreach ($tree as $treeRow) {

              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 = $this->get('share');

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

                          ->where(['tabid' => $modules, 'fieldparams' => (string) $templateId, 'presence' => [0, 2]])

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

                  }

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

                              'id' => $treeID,

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

                              'icon' => $icon,

              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

                      $share = static::getShareFromArray($this->get('share'));

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

                              $this->insertData($tree, 0, '');

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

                              ->update('vtiger_trees_templates', ['name' => $this->get('name'), 'tabid' => $this->get('tabid'), 'share' => $share], ['templateid' => $templateId])

              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

                          'depth' => $depth,

              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

                          $tree[] = $parameters;

              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 save the tree.

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

                  public function replaceValue($tree, $templateId)

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

                          $tableName = $row['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

                      $templateId = $this->getId();

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

                      }

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

                          $cut = \strlen('::' . $row['tree']);

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

                              'li_attr' => [

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

                                  'key' => $row['name'],

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

                              }

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

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

                          foreach ($this->get('tree') as $tree) {

              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

                      $modules[] = $this->get('tabid');

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

                          $uiType = (int) $row['uitype'];

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

                          'icon' => $tree['icon'],

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

                   * Get tree.

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

                      $dataReader = (new App\Db\Query())->from('vtiger_trees_templates_data')

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

                              'state' => ($row['state']) ? \App\Json::decode($row['state']) : '',

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

                      $dataReader->close();

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

                   *

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

                  /**

              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 (309 === $uiType) {

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

                                  $params = [];

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

                          return $tree;

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

                          ->where(['templateid' => $templateId])

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

                      $treeValue = $treeValue ? explode(',', $treeValue) : [];

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

                                  $parameters[$category] = ['checked' => 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

                          if ($val) {

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

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

                          $this->set('templateid', $db->getLastInsertID('vtiger_trees_templates_templateid_seq'));

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

                      }

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

                          ->from('vtiger_field')

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

                          ->createCommand()->query();

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

                      ];

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

                          }

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

                   * @param string $category

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

                      $lastId = 0;

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

                          $parentTree = substr($row['parentTree'], 0, -$cut);

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

                              if ($treeValue && \in_array($row['tree'], $treeValue)) {

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

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

                                      $params[] = 'T' . $new;

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

                      $tree = [];

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

                      }

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

                          $treeID = (int) str_replace('T', '', $row['tree']);

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

                      }

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

                              $val = !\is_array($val) ? array_filter(explode(',', $val)) : $val;

              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

                      $templateId = $this->getId();

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

                              ->insert('vtiger_trees_templates', ['name' => $this->get('name'), 'tabid' => $this->get('tabid'), 'share' => $share])

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

                          foreach ($this->get('tree') as $tree) {

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

                              $this->updateCategoryMultipicklist($tree, $tableName, $columnName);

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

                   * @param string $treeValue

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

                   */

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

                          $parent = (int) str_replace('T', '', end($pieces));

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

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

                          if ($treeID > $lastId) {

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

                      return $tree;

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

                   */

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

                              $val = [];

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

                          }

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

                          $db->createCommand()->delete('vtiger_trees_templates_data', ['templateid' => $templateId])

              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 ($row = $dataReader->read()) {

              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

                              $this->insertData($treeChild, $depth + 1, $parentTree);

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

                          if ($icon && false !== strpos($icon, '/') && !IS_PUBLIC_DIR) {

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

                   * @return mixed

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

                          $this->replaceValue($this->get('replace'), $templateId);

              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 getTree($category = false, $treeValue = false)

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

                      if ('share' === $key) {

              Line exceeds 120 characters; contains 164 characters
              Open

                              ->update('vtiger_trees_templates', ['name' => $this->get('name'), 'tabid' => $this->get('tabid'), 'share' => $share], ['templateid' => $templateId])

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

                          'label' => $label,

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

                   * @return bool|array

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

                      $module = $this->get('tabid');

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

                          }

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

                              'parent' => 0 === $parent ? '#' : $parent,

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

                          ];

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

                      }

              Line exceeds 120 characters; contains 133 characters
              Open

                              ->insert('vtiger_trees_templates', ['name' => $this->get('name'), 'tabid' => $this->get('tabid'), 'share' => $share])

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

                                  foreach ($treeRow['old'] as $new) {

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

                                  $db->createCommand()

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

                   * @param array  $tree

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

                   * @param string $columnName

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

                  }

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

                   * Gets elements of tree with given value.

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

                          $tree = $row['tree'];

              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

                      $moduleInstance = Settings_Vtiger_Module_Model::getInstance('Settings:TreesManager');

              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

                      }

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

                   */

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

                      $templateId = (new App\Db\Query())->select(['fieldparams'])

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

                          ->from('vtiger_field')

              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 int $record

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

                  public static function getInstanceById($record)

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

                      return $instance;

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

                  }

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

                              $parentTree = substr($parentTree, 0, -$cut);

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

                      $row = (new \App\Db\Query())->from('vtiger_trees_templates')->where(['templateid' => $record])->one();

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

                  public function getEditViewStructure(): array

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

                      $structure = [];

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

                          while ($rowTree = $dataReaderTree->read()) {

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

                                  [$columnName => $rowTree[$columnName]]

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

                  public static function getChildren(string $fieldValue, string $fieldName, Vtiger_Module_Model $moduleModel)

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

                  {

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

                          ->where(['tabid' => $moduleModel->getId(), 'columnname' => $fieldName, 'presence' => [0, 2]])

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

                      $dataReader = (new App\Db\Query())->from('vtiger_trees_templates_data')

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

                          if ($row['depth'] > 0) {

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

                  {

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

                      $key = 'Clean';

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

                   * Get share string from array.

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

                   * @param array()|null $share

              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::delete('TreeValuesById', $this->getId());

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

                  /** @var string[] Fields to edit */

              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->close();

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

                   * Update category multipicklist.

              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

                      $db->createCommand()->delete('vtiger_trees_templates', ['templateid' => $templateId])->execute();

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

                   * @param \Vtiger_Module_Model $moduleModel

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

                   * @return string

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

                   * @return $this|null instance, if exists. Null otherwise

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

                      }

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

                      }

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

                      \App\Cache::staticSave($cacheName, $key, clone $instance);

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

                   *

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

                  /**

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

                      foreach ($this->editFields as $fieldName) {

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

                          $dataReaderTree->close();

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

                      }

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

                   *

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

                   * @param string               $fieldName

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

                              $pieces = explode('::', $parentTree);

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

                   *

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

                   *

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

                  public static function getShareFromArray($share)

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

                  {

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

                                      ->update($tableName, [$columnName => 'T' . current($treeRow['new'])], [$columnName => $params])

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

                  /**

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

                                  [$columnName => str_replace(",T{$treeRow['old'][0]},", ",T{$treeRow['new'][0]},", $rowTree[$columnName])],

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

                      $templateId = $this->getId();

              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

                              $parent = end($pieces);

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

                              $values[] = $tree;

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

                  }

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

                      $instance = new self();

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

                      return $share ? ',' . implode(',', $share) . ',' : '';

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

                   *

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

                                  }

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

                   *

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

                          $query->orWhere(['like', $columnName, ",T{$treeRow['old'][0]},"]);

              Line exceeds 120 characters; contains 126 characters
              Open

                                  [$columnName => str_replace(",T{$treeRow['old'][0]},", ",T{$treeRow['new'][0]},", $rowTree[$columnName])],

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

                          ->where(['templateid' => $templateId])

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

                          if ($parent && \in_array($parent, $values) && !\in_array($tree, $values)) {

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

                      return implode('##', $values);

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

                      $cacheName = __CLASS__;

              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 updateCategoryMultipicklist(array $tree, string $tableName, string $columnName)

              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

                              $dbCommand->update(

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

                                  $tableName,

              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

                   * @param string $tableName

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

                          $query = (new \App\Db\Query())->from($tableName);

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

                   * Function to delete the role.

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

                      $this->clearCache();

              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 ($row = $dataReader->read()) {

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

                  /**

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

                          $instance = self::getCleanInstance();

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

                   * @return \self

              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 clears cache.

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

                   * @return void

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

                  public $editFields = ['name', 'tabid', 'share'];

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

                  /**

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

                          $fieldModel = $this->getFieldInstanceByName($fieldName);

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

                   *

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

                          }

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

                   * Function to get the instance of Role model, given role id.

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

                   *

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

                      $instance = null;

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

                          $instance->setData($row);

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

                  public static function getCleanInstance()

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

                   * @return string

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

                   */

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

                  public function delete()

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

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

                      $values = explode('##', $fieldValue);

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

                          $parent = '';

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

              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

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

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

                   * @param \Vtiger_Module_Model $moduleMode

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

                          ->scalar();

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

                  /**

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

                      return $instance;

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

                  public function clearCache(): void

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

                   *

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

                   */

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

                  {

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

                  /**

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

                              $cut = \strlen('::' . $tree);

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

                   * Function to get the clean instance.

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

                   * Get structure fields.

              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

                      $dataReader->close();

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

                   *

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

                          return clone \App\Cache::staticGet($cacheName, $key);

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

                      $instance->module = $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

                   * @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

                  public function getFieldInstanceByName(string $name)

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

                      $qualifiedModuleName = 'Settings:TreesManager';

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

                              $params = [

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

                                  'label' => 'LBL_MODULE',

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

                                  'typeofdata' => 'V~O',

              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

                              'selected' => \App\Validator::bool($branch['state']['selected']) ? $branch['state']['selected'] : false,

              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

                              $fieldInstance = $this->getFieldInstanceByName($name);

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

                      foreach ($tree as $treeRow) {

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

                   */

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

                              $fieldModel->set('fieldvalue', $defaultValue ?? '');

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

                              $parentTree = $row['parentTree'];

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

                                  'purifyType' => \App\Purifier::TEXT,

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

                                  'column' => $name,

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

                      if (\App\Cache::staticHas($cacheName, $key)) {

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

                                  'picklistValues' => [],

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

                  {

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

                   * Get field instance by name.

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

                              $params = [

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

                                  $params['picklistValues'][$moduleModel->getId()] = \App\Language::translate($moduleModel->getName(), $moduleModel->getName());

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

                              break;

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

                                  'maximumlength' => '255',

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

                                  'column' => $name,

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

                                  'tooltip' => 'LBL_DESCRIPTION_PREFIXES'

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

                              break;

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

                              'opened' => \App\Validator::bool($branch['state']['opened']) ? $branch['state']['opened'] : false,

              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

                              if (0 === strpos($icon, 'public_html/')) {

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

                          $icon = \App\Purifier::decodeHtml($branch['icon'] ?? '');

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

                          case 'tabid':

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

                      return $values;

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

                              $value = \App\Language::translate($this->get($name), $this->getModule()->getName(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

                          case 'tabid':

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

                                  'maximumlength' => '32767',

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

                                  'maximumlength' => '25',

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

                      $values = [];

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

                              $value['children'] = $this->parseTreeDataForSave($branch['children']);

              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

                          } 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

                   *

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

                              }

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

                              break;

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

                          case 'tree':

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

                                  'purifyType' => \App\Purifier::TEXT,

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

                          default:

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

                      foreach ($tree as $branch) {

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

                          $value['id'] = (int) $branch['id'];

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

                          } elseif ($icon && ('1' === $icon || !\App\Validator::fontIcon($icon))) {

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

                              $moduleName = \App\Module::getModuleName($this->get($name));

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

                              $defaultValue = $fieldModel->get('defaultvalue');

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

                      $params = [];

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

                      switch ($name) {

              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

                   *

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

                          $values[] = $value;

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

                      switch ($name) {

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

                              break;

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

                          if ($this->has($fieldName)) {

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

                          case 'share':

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

                                  'picklistValues' => []

              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

                                  'uitype' => 1,

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

                   */

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

                                  $icon = substr($icon, 12);

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

              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

                                  'column' => $name,

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

                              foreach ($this->getModule()->getSupportedModules() as $moduleModel) {

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

                                  $params['picklistValues'][$moduleModel->getId()] = \App\Language::translate($moduleModel->getName(), $moduleModel->getName());

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

                                  'label' => 'LBL_PREFIX',

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

                              break;

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

                          $value['state'] = [

              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

                              $params = [

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

                                  'typeofdata' => 'V~M',

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

                                  'label' => 'LBL_SHARE_WITH',

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

                  public function parseTreeDataForSave(array $tree): 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

                          if ($icon && false !== strpos($icon, '/')) {

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

                              $icon = '';

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

                   * Function to get the Display Value, for the current field type with given DB Insert Value.

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

                                  'label' => 'LBL_NAME',

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

                                  'maximumlength' => 255,

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

                              'disabled' => \App\Validator::bool($branch['state']['disabled']) ? $branch['state']['disabled'] : 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

                              $fieldModel->set('fieldvalue', $this->get($fieldName));

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

                  {

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

                          case '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

                                  'typeofdata' => 'V~M',

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

                              }

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

                          $value = [];

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

                              $icon = \App\Purifier::purifyByType($icon, \App\Purifier::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

                          case '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

                              foreach ($this->getModule()->getSupportedModules() as $moduleModel) {

              Line exceeds 120 characters; contains 146 characters
              Open

                                  $params['picklistValues'][$moduleModel->getId()] = \App\Language::translate($moduleModel->getName(), $moduleModel->getName());

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

                                  'typeofdata' => 'V~O',

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

                              $params = [

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

                              ];

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

                   * Parse tree data for save.

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

                  {

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

                  /**

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

                              $value = \App\Language::translate($moduleName, $moduleName);

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

                              $value = $fieldInstance->getDisplayValue($this->get($name), false, false, 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

                          $structure[$fieldName] = $fieldModel;

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

                                  'purifyType' => \App\Purifier::INTEGER,

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

                                  'purifyType' => \App\Purifier::INTEGER,

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

                                  'column' => $name,

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

                      return $params ? \Vtiger_Field_Model::init($qualifiedModuleName, $params, $name) : null;

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

                   * @return string

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

                              break;

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

                                  'uitype' => 1,

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

                              break;

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

                                  'uitype' => 16,

              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

                              'loaded' => \App\Validator::bool($branch['state']['loaded']) ? $branch['state']['loaded'] : 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

                          default:

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

                              break;

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

                                  'isEditableReadOnly' => !empty($this->getId())

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

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

                          $value['icon'] = $icon;

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

                          if (!empty($branch['children'])) {

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

                   * @return Vtiger_Field_Model

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

                                  'uitype' => 33,

              Line exceeds 120 characters; contains 146 characters
              Open

                                  $params['picklistValues'][$moduleModel->getId()] = \App\Language::translate($moduleModel->getName(), $moduleModel->getName());

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

                      }

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

                          $value['text'] = \App\Purifier::decodeHtml($branch['text']);

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

                  public function getDisplayValue(string $name)

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

              class Settings_TreesManager_Record_Model extends Settings_Vtiger_Record_Model

              There are no issues that match your filters.

              Category
              Status