YetiForceCompany/YetiForceCRM

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

Summary

Maintainability
D
2 days
Test Coverage
F
38%

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

class Settings_WebserviceUsers_Record_Model extends Settings_Vtiger_Record_Model
{
    /**
     * Changes.
     *

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

<?php

/**
 * Record Model.
 *
Severity: Minor
Found in modules/Settings/WebserviceUsers/models/Record.php - About 3 hrs to fix

    Settings_WebserviceUsers_Record_Model has 21 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Settings_WebserviceUsers_Record_Model extends Settings_Vtiger_Record_Model
    {
        /**
         * Changes.
         *
    Severity: Minor
    Found in modules/Settings/WebserviceUsers/models/Record.php - About 2 hrs to fix

      Function getFormatDataSession has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          public function getFormatDataSession(array $row): array
          {
              foreach ($row as $key => $value) {
                  switch ($key) {
                      case 'parent_id':
      Severity: Minor
      Found in modules/Settings/WebserviceUsers/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 save has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          public function save()
          {
              $db = App\Db::getInstance('webservice');
              $table = $this->baseTable;
              $index = $this->baseIndex;
      Severity: Minor
      Found in modules/Settings/WebserviceUsers/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 save has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function save()
          {
              $db = App\Db::getInstance('webservice');
              $table = $this->baseTable;
              $index = $this->baseIndex;
      Severity: Minor
      Found in modules/Settings/WebserviceUsers/models/Record.php - About 1 hr to fix

        Method getFormatDataSession has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getFormatDataSession(array $row): array
            {
                foreach ($row as $key => $value) {
                    switch ($key) {
                        case 'parent_id':
        Severity: Minor
        Found in modules/Settings/WebserviceUsers/models/Record.php - About 1 hr to fix

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

              public function getFormatLoginHistory(array $row): array
              {
                  foreach ($row as $key => $value) {
                      switch ($key) {
                          case 'time':
          Severity: Minor
          Found in modules/Settings/WebserviceUsers/models/Record.php - About 55 mins to fix

          Cognitive Complexity

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

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

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

          Further reading

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

              public function checkData()
              {
                  if (empty($this->listFields['user_name'])) {
                      return false;
                  }
          Severity: Minor
          Found in modules/Settings/WebserviceUsers/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

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

              public static function getInstanceById($id, $type)
              {
                  $cacheName = __CLASS__;
                  if (\App\Cache::staticHas($cacheName, $id)) {
                      return \App\Cache::staticGet($cacheName, $id);
          Severity: Minor
          Found in modules/Settings/WebserviceUsers/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 getFormatDataSession() has a Cyclomatic Complexity of 13. The configured cyclomatic complexity threshold is 10.
          Open

              public function getFormatDataSession(array $row): array
              {
                  foreach ($row as $key => $value) {
                      switch ($key) {
                          case 'parent_id':

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

              public function save()
              {
                  $db = App\Db::getInstance('webservice');
                  $table = $this->baseTable;
                  $index = $this->baseIndex;

          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

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

          class Settings_WebserviceUsers_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.

          Reduce the number of returns of this function 4, down to the maximum allowed 3.
          Open

              public function checkData()

          Having too many return statements in a function increases the function's essential complexity because the flow of execution is broken each time a return statement is encountered. This makes it harder to read and understand the logic of the function.

          Noncompliant Code Example

          With the default threshold of 3:

          function myFunction(){ // Noncompliant as there are 4 return statements
            if (condition1) {
              return true;
            } else {
              if (condition2) {
                return false;
              } else {
                return true;
              }
            }
            return false;
          }
          

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

              public function getFormatDataSession(array $row): 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

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

                  $dataReader = (new \App\Db\Query())->from(\Api\Core\Containers::$listTables[$container]['loginHistory'])

          UndefinedVariable

          Since: 2.8.0

          Detects when a variable is used that has not been defined before.

          Example

          class Foo
          {
              private function bar()
              {
                  // $message is undefined
                  echo $message;
              }
          }

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

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

                  $dataReader = (new \App\Db\Query())->from(\Api\Core\Containers::$listTables[$container]['session'])

          UndefinedVariable

          Since: 2.8.0

          Detects when a variable is used that has not been defined before.

          Example

          class Foo
          {
              private function bar()
              {
                  // $message is undefined
                  echo $message;
              }
          }

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

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

          class Settings_WebserviceUsers_Record_Model extends Settings_Vtiger_Record_Model
          {
              /**
               * Changes.
               *

          CouplingBetweenObjects

          Since: 1.1.0

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

          Example

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

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

          Missing class import via use statement (line '163', column '22').
          Open

                  $dataReader = (new \App\Db\Query())->from(\Api\Core\Containers::$listTables[$container]['session'])

          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 '279', column '37').
          Open

                          $fieldObjects[$fieldName] = new \App\Base(['name' => $fieldName, 'label' => $fieldLabel]);

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

                  $dataReader = (new \App\Db\Query())->from(\Api\Core\Containers::$listTables[$container]['loginHistory'])

          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 '378', column '13').
          Open

                      if ((new App\Db\Query())

          MissingImport

          Since: 2.7.0

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

          Example

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

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

          Missing class import via use statement (line '301', column '16').
          Open

                  $data = (new App\Db\Query())

          MissingImport

          Since: 2.7.0

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

          Example

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

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

          Avoid using static access to class '\App\Language' in method 'getFormatDataSession'.
          Open

                                      $value .= \App\Language::translate(self::$customParamsLabels[$paramsKey] ?? $paramsKey, 'Settings:WebserviceUsers') . ": $paramsValue \n";

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

                  } else {
                      $data['auth'] = [];
                  }

          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('webservice');

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

                                  $params = \App\Json::decode($value);

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

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

          StaticAccess

          Since: 1.4.0

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

          Example

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

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

          Avoid using static access to class '\App\Fields\DateTime' in method 'getFormatDataSession'.
          Open

                              $row[$key] = \App\Fields\DateTime::formatToDisplay($value);

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

                      $this->module = Settings_Vtiger_Module_Model::getInstance('Settings:WebserviceUsers');

          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\Layout' in method 'getFormatLoginHistory'.
          Open

                              $row[$key] = \App\Layout::truncateText($value, 50, 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\Db' in method 'getInstanceById'.
          Open

                      ->one(App\Db::getInstance('webservice'));

          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\Record' in method 'getFormatDataSession'.
          Open

                              $row[$key] = $value ? \App\Record::getLabel($value) : '';

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

                              $row[$key] = $value ? \App\Language::getLanguageLabel($value) : '';

          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\Layout' in method 'getFormatDataSession'.
          Open

                                  $row[$key] = \App\Layout::truncateText($value, 50, 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\Purifier' in method 'getFormatDataSession'.
          Open

                          $row[$key] = App\Purifier::encodeHtml($row[$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\TextUtils' in method 'getFormatLoginHistory'.
          Open

                              $row[$key] = "<div class=\"js-popover-tooltip ml-2 mr-2 d-inline mt-2\" data-js=\"popover\" data-content=\"$value\">" . \App\TextUtils::textTruncate($value, 14) . '</div>';

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

                          ->exists(App\Db::getInstance('webservice'))) {

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

                      $data['custom_params'] = \App\Json::decode($data['custom_params']);

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

                  \App\Cache::staticSave($cacheName, $id, $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

          Avoid using static access to class '\App\Language' in method 'getFormatLoginHistory'.
          Open

                                  $row[$key] = \App\Language::translate($value, 'Settings::' . $this->getModule()->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

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

                  } else {
                      $data['custom_params'] = [];
                  }

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

                          $row[$key] = App\Purifier::encodeHtml($row[$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\Json' in method 'getInstanceById'.
          Open

                  if (!empty($data['custom_params']) && !App\Json::isEmpty($data['custom_params'])) {

          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 {
                      $auth = $this->get('auth') ?: [];
                      $auth['authy_methods'] = $data['authy_methods'] ?? '';
                      $data['auth'] = \App\Encryption::getInstance()->encrypt(\App\Json::encode($auth));
                  }

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

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

          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('webservice');

          StaticAccess

          Since: 1.4.0

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

          Example

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

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

          Avoid assigning values to variables in if clauses and the like (line '462', column '7').
          Open

              public function delete()
              {
                  $db = App\Db::getInstance('webservice');
                  $result = false;
                  if ($recordId = $this->getId()) {

          IfStatementAssignment

          Since: 2.7.0

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

          Example

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

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

          Avoid assigning values to variables in if clauses and the like (line '137', column '8').
          Open

              public function set($key, $value)
              {
                  if (($prev = $this->value[$key] ?? null) !== $value) {
                      $this->changes[$key] = $prev;
                  }

          IfStatementAssignment

          Since: 2.7.0

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

          Example

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

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

          Avoid using static access to class '\App\Fields\DateTime' in method 'getFormatLoginHistory'.
          Open

                              $row[$key] = \App\Fields\DateTime::formatToDisplay($value);

          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\Layout' in method 'getFormatDataSession'.
          Open

                                  $row[$key] = \App\Layout::truncateText($value, 50, 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\Json' in method 'getInstanceById'.
          Open

                      $data['auth'] = \App\Json::decode(\App\Encryption::getInstance()->decrypt($data['auth']));

          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 {
                      $success = $db->createCommand()->update($table, $data, [$index => $this->getId()])->execute();
                  }

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

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

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

                  } else {
                      $email = \App\User::getUserModel($this->get('user_id'))->getDetail('email1');
                  }

          ElseExpression

          Since: 1.4.0

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

          Example

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

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

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

                  } else {
                      $fields = $this->getFieldsForSave();
                  }

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

                      $data['auth'] = \App\Encryption::getInstance()->encrypt(\App\Json::encode($auth));

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

                  $data['custom_params'] = $params ? \App\Json::encode($params) : 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

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

                      ->where(['user_id' => $this->getId()])

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

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

          Noncompliant Code Example

          With the default threshold of 3:

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

          Compliant Solution

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

          Exceptions

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

          Define a constant instead of duplicating this literal "Settings:WebserviceUsers" 3 times.
          Open

                      $this->module = Settings_Vtiger_Module_Model::getInstance('Settings:WebserviceUsers');

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

                      ->one(App\Db::getInstance('webservice'));

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

                  $data['authy_methods'] = $data['auth']['authy_methods'] ?? '';

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

                  if (!empty($data['custom_params']) && !App\Json::isEmpty($data['custom_params'])) {

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

                  'agent' => 'LBL_USER_AGENT',

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

                  if (empty($this->listFields['user_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.

          Avoid using empty try-catch blocks in getUserName.
          Open

                      } catch (\Throwable $th) {
                      }

          EmptyCatchBlock

          Since: 2.7.0

          Usually empty try-catch is a bad idea because you are silently swallowing an error condition and then continuing execution. Occasionally this may be the right thing to do, but often it's a sign that a developer saw an exception, didn't know what to do about it, and so used an empty catch to silence the problem.

          Example

          class Foo {
          
            public function bar()
            {
                try {
                    // ...
                } catch (Exception $e) {} // empty catch block
            }
          }

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

          Reference to undeclared property \Settings_WebserviceUsers_Record_Model->module
          Open

                  return $this->module;

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

              public static function getInstanceById($id, $type)

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

                  $dataReader = (new \App\Db\Query())->from(\Api\Core\Containers::$listTables[$container]['loginHistory'])

          Reference to undeclared property \Settings_WebserviceUsers_Record_Model->listFieldModels
          Open

                  return $this->listFieldModels;

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

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

          Call to method getInstance from undeclared class \App\Encryption (Did you mean class \Tests\App\Encryption)
          Open

                      $data['auth'] = \App\Json::decode(\App\Encryption::getInstance()->decrypt($data['auth']));

          Reference to undeclared property \Settings_WebserviceUsers_Record_Model->listFieldModels
          Open

                  if (!isset($this->listFieldModels)) {

          Reference to undeclared property \Settings_WebserviceUsers_Record_Model->module
          Open

                  if (!$this->module) {

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

                  $data = (new App\Db\Query())

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

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

          Returning type bool but isNew() is declared to return int
          Open

                  return !$this->getId() || $this->getId() && \array_key_exists('id', $this->changes) && empty($this->changes['id']);

          Reference to undeclared property \Settings_WebserviceUsers_Record_Model->module
          Open

                      $this->module = Settings_Vtiger_Module_Model::getInstance('Settings:WebserviceUsers');

          Reference to undeclared property \Settings_WebserviceUsers_Record_Model->listFieldModels
          Open

                      $this->listFieldModels = $fieldObjects;

          Call to undeclared method \Settings_Vtiger_Module_Model::getService
          Open

                  $instance = $moduleInstance->getService();

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

                      $email = \App\User::getUserModel($this->get('user_id'))->getDetail('email1');

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

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

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

                      if ((new App\Db\Query())

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

                      $result = (bool) $db->createCommand()->delete($this->baseTable, [$this->baseIndex => $recordId])->execute();

          Reference to undeclared property \Settings_WebserviceUsers_Record_Model->module
          Open

                  $this->module = $moduleModel;

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

                  $dataReader = (new \App\Db\Query())->from(\Api\Core\Containers::$listTables[$container]['session'])

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

                      $success = $db->createCommand()->insert($table, $data)->execute();

          Reference to undeclared property \Settings_Vtiger_Module_Model->typeApi
          Open

                  $moduleInstance->typeApi = $type;

          Call to method getInstance from undeclared class \App\Encryption (Did you mean class \Tests\App\Encryption)
          Open

                      $data['auth'] = \App\Encryption::getInstance()->encrypt(\App\Json::encode($auth));

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

                      $success = $db->createCommand()->update($table, $data, [$index => $this->getId()])->execute();

          Either remove or fill this block of code.
          Open

                      } catch (\Throwable $th) {
                      }

          Most of the time a block of code is empty when a piece of code is really missing. So such empty block must be either filled or removed.

          Noncompliant Code Example

          for ($i = 0; $i < 42; $i++){}  // Empty on purpose or missing piece of code ?
          

          Exceptions

          When a block contains a comment, this block is not considered to be empty.

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

              public function getUserSession(string $container): array
              {
                  $dataReader = (new \App\Db\Query())->from(\Api\Core\Containers::$listTables[$container]['session'])
                      ->where(['user_id' => $this->getId()])
                      ->orderBy(['changed' => SORT_DESC])
          Severity: Major
          Found in modules/Settings/WebserviceUsers/models/Record.php and 1 other location - About 1 hr to fix
          modules/Settings/WebserviceUsers/models/Record.php on lines 182..194

          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 115.

          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 function getUserHistoryAccessActivity(string $container): array
              {
                  $dataReader = (new \App\Db\Query())->from(\Api\Core\Containers::$listTables[$container]['loginHistory'])
                      ->where(['user_id' => $this->getId()])
                      ->orderBy(['id' => SORT_DESC])
          Severity: Major
          Found in modules/Settings/WebserviceUsers/models/Record.php and 1 other location - About 1 hr to fix
          modules/Settings/WebserviceUsers/models/Record.php on lines 161..173

          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 115.

          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_WebserviceUsers_Record_Model extends Settings_Vtiger_Record_Model

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

              public static function getInstanceById($id, $type)

          ShortVariable

          Since: 0.2

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

          Example

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

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

          The class Settings_WebserviceUsers_Record_Model is not named in CamelCase.
          Open

          class Settings_WebserviceUsers_Record_Model extends Settings_Vtiger_Record_Model
          {
              /**
               * Changes.
               *

          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('webservice');

          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('webservice');

          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

          Terminating statement must be indented to the same level as the CASE body
          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

               */

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

               *

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

               * Changes.

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

              public $changes = [];

          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

               * Table name.

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

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

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

                  'error_time' => 'FL_LAST_ERROR_DATE',

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

                  'error_method' => 'FL_LAST_ERROR_METHOD',

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

               * @return int

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

               * Check if record is new.

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

               * @param string $container

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

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

               * @param Settings_WebserviceUsers_Module_Model $moduleModel

          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

                  return $this;

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

                  $this->setData($data);

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

                      ->limit(30)

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

                  $data = [];

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

                  $data = [];

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

                  'deviceId' => 'LBL_DEVICE_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

              /** {@inheritdoc} */

          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 $baseTable = '';

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

              public $name = 'WebserviceUsers';

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

               * Edit fields.

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

               *

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

                  'language' => 'FL_LANGUAGE',

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

                  'fromUrl' => 'FL_FROM_URL',

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

                  'agent' => 'LBL_USER_AGENT',

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

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

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

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

                  parent::set($key, $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

              public function getUserHistoryAccessActivity(string $container): array

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

                      ->orderBy(['id' => SORT_DESC])

          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

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

               *

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

          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 = Settings_Vtiger_Module_Model::getInstance('Settings:WebserviceUsers');

          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

                      ->where(['user_id' => $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

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

              /** @var array List of fields in param column. */

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

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

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

               */

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

                  }

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

              }

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

               * @param string $container

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

                      ->where(['user_id' => $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

               * @var string[]

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

              public $paramsFields = [];

          Line exceeds 120 characters; contains 123 characters
          Open

                  return !$this->getId() || $this->getId() && \array_key_exists('id', $this->changes) && empty($this->changes['id']);

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

              /**

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

               */

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

              public function getModule()

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

               * Function to set Module instance.

          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

              /** {@inheritdoc} */

          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 determines fields available in edition 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

                      ->limit(30)

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

               * @var 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 $editFields = [];

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

              /** @var array List of custom params labels. */

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

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

               */

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

                  }

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

               *

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

               *

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

               * @return Settings_WebserviceUsers_Module_Model

          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

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

                  return $this->editFields;

          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

               * List of fields displayed in list view.

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

                  'invalid_login_time' => 'FL_DATETIME_LAST_INVALID_LOGIN',

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

              }

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

              }

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

               *

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

               */

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

               */

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

              ];

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

              }

          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

                      ->orderBy(['changed' => SORT_DESC])

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

               * Get user session.

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

               * Table name.

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

                  'invalid_login' => 'FL_LAST_INVALID_LOGIN',

          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

              public function set($key, $value)

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

              public function getEditFields()

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

                  $dataReader = (new \App\Db\Query())->from(\Api\Core\Containers::$listTables[$container]['session'])

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

                  return $data;

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

              {

          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

                  'ip' => 'FL_LAST_IP',

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

                  'logout_time' => 'FL_LOGOUT_TIME',

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

                  'last_error' => 'FL_LAST_ERROR',

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

               * Record ID.

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

               */

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

               * @return int

          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->module;

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

                  if (($prev = $this->value[$key] ?? null) !== $value) {

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

              /**

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

              /**

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

              public function getUserSession(string $container): 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

              public $baseIndex = '';

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

                  return !$this->getId() || $this->getId() && \array_key_exists('id', $this->changes) && empty($this->changes['id']);

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

              public function init(array $data)

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

              {

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

               * Get user session.

          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

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

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

                      $data[] = $this->getFormatDataSession($row);

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

                  $dataReader = (new \App\Db\Query())->from(\Api\Core\Containers::$listTables[$container]['loginHistory'])

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

                          case 'parent_id':

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

                      $this->listFieldModels = $fieldObjects;

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

              public function getFormatLoginHistory(array $row): array

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

                              $row[$key] = "<div class=\"js-popover-tooltip ml-2 mr-2 d-inline mt-2\" data-js=\"popover\" data-content=\"$value\">" . \App\TextUtils::textTruncate($value, 14) . '</div>';

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

              public static function getInstanceById($id, $type)

          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

                  } 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

                  $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

               * Module Name.

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

              public static $customParamsLabels = [

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

                  'version' => 'FL_VERSION',

          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

                      $this->changes[$key] = $prev;

          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

               * @return array

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

                      switch ($key) {

          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 'created':

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

                          case 'changed':

          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

                                  $row[$key] = \App\Layout::truncateText($value, 50, true);

          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

                      }

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

                      $fieldObjects = [];

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

                  if (!empty($data['auth'])) {

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

                  \App\Cache::staticSave($cacheName, $id, $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

                              break;

          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 (!\in_array($key, ['device_id', 'agent'])) {

          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

                          case 'params':

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

                  }

          Line exceeds 120 characters; contains 192 characters
          Open

                              $row[$key] = "<div class=\"js-popover-tooltip ml-2 mr-2 d-inline mt-2\" data-js=\"popover\" data-content=\"$value\">" . \App\TextUtils::textTruncate($value, 14) . '</div>';

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

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

                      $data['custom_params'] = \App\Json::decode($data['custom_params']);

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

                  $data['authy_methods'] = $data['auth']['authy_methods'] ?? '';

          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 getFormatDataSession(array $row): array

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

                              case 'agent':

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

               *

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

                          $row[$key] = App\Purifier::encodeHtml($row[$key]);

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

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

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

                      ->from($instance->baseTable)

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

                      $data['custom_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

               * @return $this

          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

                              $row[$key] = $value ? \App\Language::getLanguageLabel($value) : '';

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

                      }

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

              }

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

                              $row[$key] = \App\Fields\DateTime::formatToDisplay($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

                  $instance = self::getCleanInstance($type);

          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

                  $instance = $moduleInstance->getService();

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

                  return $data;

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

                              if ($value) {

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

                      if (!\in_array($key, ['params', 'agent'])) {

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

                      $data = array_merge($data, $data['custom_params']);

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

                  $instance->init($data);

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

               * @param string $type

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

                      $data[] = $this->getFormatLoginHistory($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

                          case 'language':

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

                                  $params = \App\Json::decode($value);

          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

                      foreach ($this->listFields as $fieldName => $fieldLabel) {

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

                      $data['auth'] = \App\Json::decode(\App\Encryption::getInstance()->decrypt($data['auth']));

          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

               * Get format data session.

          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

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

                              $row[$key] = \App\Layout::truncateText($value, 50, true);

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

                  foreach ($row as $key => $value) {

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

                  }

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

                                  }

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

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

              {

          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, given id.

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

                          case 'status':

          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

                          case 'device_id':

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

                      }

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

              }

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

                  $data = (new App\Db\Query())

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

                  }

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

               * @return array

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

                  }

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

                              $row[$key] = $value ? \App\Record::getLabel($value) : '';

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

                                  foreach ($params as $paramsKey => $paramsValue) {

          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

                          case 'agent':

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

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

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

                  if (!empty($data['custom_params']) && !App\Json::isEmpty($data['custom_params'])) {

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

                      $data['auth'] = [];

          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(self::$customParamsLabels[$paramsKey] ?? $paramsKey, 'Settings:WebserviceUsers') . ": $paramsValue \n";

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

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

                              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

              }

          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

                                  $row[$key] = \App\Layout::truncateText($value, 50, true);

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

                          $row[$key] = App\Purifier::encodeHtml($row[$key]);

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

               * Get format data session.

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

               * @param array $row

          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

                  return $this->listFieldModels;

          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

              public static function getCleanInstance($type): self

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

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

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

               * @param array $row

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

                          case 'time':

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

                                  $row[$key] = \App\Language::translate($value, 'Settings::' . $this->getModule()->getName());

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

                          $fieldObjects[$fieldName] = new \App\Base(['name' => $fieldName, 'label' => $fieldLabel]);

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

               * @param string $type

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

               *

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

                      ->where([$instance->baseIndex => $id])

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

              }

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

               * @return array

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

                              $row[$key] = \App\Fields\DateTime::formatToDisplay($value);

          Line exceeds 120 characters; contains 166 characters
          Open

                                      $value .= \App\Language::translate(self::$customParamsLabels[$paramsKey] ?? $paramsKey, 'Settings:WebserviceUsers') . ": $paramsValue \n";

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

                  foreach ($row as $key => $value) {

          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

                              break;

          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

              public function getListFields(): array

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

                  if (!isset($this->listFieldModels)) {

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

                  }

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

                      ->one(App\Db::getInstance('webservice'));

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

                  $moduleInstance->typeApi = $type;

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

               * Function gives list fields for save.

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

                  if (empty($this->getId())) {

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

               * Check if the data is correct.

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

                  return false;

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

               * Function to 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

                  $data['custom_params'] = $params ? \App\Json::encode($params) : null;

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

                  }

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

                      }

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

                      }

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

              }

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

               *

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

                  $result = false;

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

                  $index = $this->baseIndex;

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

                      $auth['authy_methods'] = $data['authy_methods'] ?? '';

          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

              {

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

                          ->exists(App\Db::getInstance('webservice'))) {

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

                      $data['auth'] = \App\Encryption::getInstance()->encrypt(\App\Json::encode($auth));

          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

               * Function gives 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

              public function checkData()

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

                          return 'LBL_DUPLICATE_EMAIL_ADDRESS';

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

                          continue;

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

                          $params[$name] = $data[$name];

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

                      $data['user_name'] = $this->getUserName();

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

               *

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

               * @return bool

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

                  return $result;

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

              }

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

                  }

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

               * @return bool

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

              {

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

                  $table = $this->baseTable;

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

                      unset($data[$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

                      $email = \App\User::getUserModel($this->get('user_id'))->getDetail('email1');

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

                  return $email;

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

          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

                  } else {

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

                          return 'LBL_EMAIL_ADDRESS_NOT_FOUND';

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

               */

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

                  $email = '';

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

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

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

                      $result = (bool) $db->createCommand()->delete($this->baseTable, [$this->baseIndex => $recordId])->execute();

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

                  foreach ($this->paramsFields as $name) {

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

                      $data['auth'] = '';

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

                      $success = $db->createCommand()->update($table, $data, [$index => $this->getId()])->execute();

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

                      try {

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

                      } catch (\Throwable $th) {

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

              {

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

                      $fields = $this->getFieldsForSave();

          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

                      if ('' !== $data[$name]) {

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

                      $success = $db->createCommand()->insert($table, $data)->execute();

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

                  if (1 !== (int) $this->get('type')) {

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

                  return array_intersect_key($this->getData(), $fields);

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

                      if ((new App\Db\Query())

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

                          ->from($this->baseTable)

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

                  $data = $this->getDataForSave();

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

                      if ($success) {

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

                  }

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

               */

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

              {

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

               * @return bool|string false - if everything is ok

          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 ($this->isEmpty('user_name')) {

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

                      $userName = $this->getUserName();

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

                  $params = $this->get('custom_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

                      $auth = $this->get('auth') ?: [];

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

                  unset($data['authy_methods']);

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

                  if (empty($this->getId())) {

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

                          $this->set('id', $db->getLastInsertID("{$table}_{$index}_seq"));

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

               * Get user name.

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

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

          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

                      $fields = $this->getEditFields();

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

                  if (empty($this->listFields['user_name'])) {

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

                      }

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

              /**

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

              }

          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

                  } else {

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

                  return $success;

          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

                          $email = Vtiger_Record_Model::getInstanceById($this->get('crmid'), 'Contacts')->get('email');

          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 removes record.

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

                  if ($recordId = $this->getId()) {

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

                      return false;

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

                      if (empty($userName)) {

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

                          ->where(['user_name' => $userName])

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

                  }

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

                  }

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

              {

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

                  return array_intersect_key($this->getEditFields(), $this->changes);

          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

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

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

                  if (empty($data['authy_methods']) || '-' === $data['authy_methods']) {

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

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

                  }

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

                      if (!isset($data[$name])) {

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

              public function getUserName(): string

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

                  $this->set('user_name', $email);

          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 (!$this->isEmpty('user_name')) {

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

          class Settings_WebserviceUsers_Record_Model extends Settings_Vtiger_Record_Model

          Line indented incorrectly; expected 16 spaces, found 20
          Open

                              case 'agent':

          There are no issues that match your filters.

          Category
          Status