YetiForceCompany/YetiForceCRM

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

Summary

Maintainability
B
5 hrs
Test Coverage
F
0%

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

class Settings_SMSNotifier_Record_Model extends Settings_Vtiger_Record_Model
{
    /** @var array Record changes */
    protected $changes = [];

Settings_SMSNotifier_Record_Model has 23 functions (exceeds 20 allowed). Consider refactoring.
Open

class Settings_SMSNotifier_Record_Model extends Settings_Vtiger_Record_Model
{
    /** @var array Record changes */
    protected $changes = [];

Severity: Minor
Found in modules/Settings/SMSNotifier/models/Record.php - About 2 hrs to fix

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

        public function getFieldInstanceByName($name)
        {
            $moduleName = $this->getModule()->getName(true);
            $params = ['uitype' => 1, 'column' => $name, 'name' => $name, 'displaytype' => 1, 'typeofdata' => 'V~M', 'presence' => 0, 'isEditableReadOnly' => false];
            switch ($name) {
    Severity: Minor
    Found in modules/Settings/SMSNotifier/models/Record.php - About 1 hr to fix

      Function setDataFromRequest has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          public function setDataFromRequest(App\Request $request)
          {
              foreach ($this->getEditFields() as $fieldName => $fieldModel) {
                  if ($request->has($fieldName)) {
                      $value = $request->isEmpty($fieldName) && !$fieldModel->isMandatory() ? '' : $request->getByType($fieldName, $fieldModel->get('purifyType'));
      Severity: Minor
      Found in modules/Settings/SMSNotifier/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 saveToDb has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          public function saveToDb()
          {
              $db = \App\Db::getInstance('admin');
              $fields = array_flip(['providertype', 'isactive', 'api_key', 'parameters', 'name']);
              $tablesData = $this->getId() ? array_intersect_key($this->getData(), $this->changes, $fields) : array_intersect_key($this->getData(), $fields);
      Severity: Minor
      Found in modules/Settings/SMSNotifier/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 getFieldInstanceByName has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          public function getFieldInstanceByName($name)
          {
              $moduleName = $this->getModule()->getName(true);
              $params = ['uitype' => 1, 'column' => $name, 'name' => $name, 'displaytype' => 1, 'typeofdata' => 'V~M', 'presence' => 0, 'isEditableReadOnly' => false];
              switch ($name) {
      Severity: Minor
      Found in modules/Settings/SMSNotifier/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

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

      class Settings_SMSNotifier_Record_Model extends Settings_Vtiger_Record_Model

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

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

      class Settings_SMSNotifier_Record_Model extends Settings_Vtiger_Record_Model
      {
          /** @var array Record changes */
          protected $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 '411', column '15').
      Open

              return (new \App\Db\Query())->from('w_#__sms_user')->where(['status' => 1])->all();

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

                      $params['picklistValues'] = [1 => \App\Language::translate('FL_ACTIVE'), 0 => \App\Language::translate('FL_INACTIVE')];

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

              return $this->get('parameters') ? \App\Json::decode($this->get('parameters')) : [];

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

                      } else {
                          $parameters = $this->getParameters();
                          $parameters[$fieldName] = $value;
                          $this->set('parameters', \App\Json::encode($parameters));
                      }

      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\Integrations\SMSProvider' in method 'getFieldInstanceByName'.
      Open

                      foreach (\App\Integrations\SMSProvider::getProviders() as $provider) {

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

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

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

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

      Avoid using static access to class '\App\Db' in method 'getInstanceById'.
      Open

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

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

                          $this->set('parameters', \App\Json::encode($parameters));

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

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

              $moduleModel = Settings_Vtiger_Module_Model::getInstance('Settings:SMSNotifier');

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

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

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

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

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

              return Settings_Vtiger_Field_Model::init($moduleName, $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\Language' in method 'getDisplayValue'.
      Open

                  return empty($this->get($name)) ? \App\Language::translate('FL_INACTIVE', "Settings:$moduleName") : \App\Language::translate('FL_ACTIVE');

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

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

                  \App\Log::error($ex->__toString());

      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

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

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

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

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

                  } else {
                      $db->createCommand()->insert($baseTable, $tablesData)->execute();
                      $this->set('id', $db->getLastInsertID("{$baseTable}_{$baseTableIndex}_seq"));
                  }

      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\Integrations\SMSProvider' in method 'getEditFields'.
      Open

              $provider = \App\Integrations\SMSProvider::getProviderByName($this->get('providertype'));

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

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

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

              \App\Cache::staticDelete(__CLASS__, $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\Language' in method 'getDisplayValue'.
      Open

                  return empty($this->get($name)) ? \App\Language::translate('FL_INACTIVE', "Settings:$moduleName") : \App\Language::translate('FL_ACTIVE');

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

              return \App\Purifier::encodeHtml($this->get($name));

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

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

                      $params['picklistValues'] = [1 => \App\Language::translate('FL_ACTIVE'), 0 => \App\Language::translate('FL_INACTIVE')];

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

                      $value = $request->isEmpty($fieldName) && !$fieldModel->isMandatory() ? '' : $request->getByType($fieldName, $fieldModel->get('purifyType'));

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

                      $params['fieldvalue'] = $this->getValueByField($name);

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

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

      Noncompliant Code Example

      With the default threshold of 3:

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

      Compliant Solution

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

      Exceptions

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

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

                      $params['picklistValues'] = [];

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

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

      Noncompliant Code Example

      With the default threshold of 3:

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

      Compliant Solution

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

      Exceptions

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

      Define a constant instead of duplicating this literal "admin" 4 times.
      Open

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

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

          private $editFields = ['name', 'isactive'];

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

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

      Noncompliant Code Example

      With the default threshold of 3:

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

      Compliant Solution

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

      Exceptions

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

      Define a constant instead of duplicating this literal "uitype" 4 times.
      Open

              $params = ['uitype' => 1, 'column' => $name, 'name' => $name, 'displaytype' => 1, 'typeofdata' => 'V~M', 'presence' => 0, 'isEditableReadOnly' => false];

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

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

      Noncompliant Code Example

      With the default threshold of 3:

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

      Compliant Solution

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

      Exceptions

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

      Define a constant instead of duplicating this literal "parameters" 4 times.
      Open

              $fields = array_flip(['providertype', 'isactive', 'api_key', 'parameters', 'name']);

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

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

      Noncompliant Code Example

      With the default threshold of 3:

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

      Compliant Solution

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

      Exceptions

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

      Define a constant instead of duplicating this literal "providertype" 6 times.
      Open

              return \App\Integrations\SMSProvider::getProviderByName($this->get('providertype'))->getEditViewUrl() . '&record=' . $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 "label" 3 times.
      Open

                      $params['label'] = 'FL_PROVIDER';

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

              $fields = array_flip(['providertype', 'isactive', 'api_key', 'parameters', '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.

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

                      $db->createCommand()->update($baseTable, $tablesData, [$baseTableIndex => (int) $this->getId()])->execute();

      Reference to undeclared property \Settings_SMSNotifier_Record_Model->isNew
      Open

              $recordModel->isNew = true;

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

           * @return <Integer> Id

      Reference to undeclared property \Settings_SMSNotifier_Record_Model->isNew
      Open

              $instance->isNew = false;

      Reference to undeclared property \Settings_SMSNotifier_Record_Model->module
      Open

              return $this->module;

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

              \App\Cache::staticDelete(__CLASS__, $id);

      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 undeclared method \App\Db::beginTransaction
      Open

              $transaction = $db->beginTransaction();

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

                      $db->createCommand()->insert($baseTable, $tablesData)->execute();

      Doc-block of $provider in getCleanInstance is phpdoc param type string which is not a permitted replacement of the nullable param type ?string declared in the signature ('?T' should be documented as 'T|null' or '?T')
      Open

           * @param string $provider

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

                  \App\Log::error($ex->__toString());

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

                          $value = App\Encryption::getInstance()->encrypt($value);

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

          public static function getInstanceById($id)

      Saw an @param annotation for qualifiedModuleName, but it was not found in the param list of function getCleanInstance(?string $provider = null) : \Settings_SMSNotifier_Record_Model|\self
      Open

           * @param string $qualifiedModuleName

      Argument 1 (moduleModel) is \App\Base|\Settings_Vtiger_Module_Model but \Settings_SMSNotifier_Record_Model::setModule() takes \Settings_SMSNotifier_Module_Model defined at /code/modules/Settings/SMSNotifier/models/Record.php:61
      Open

              return $recordModel->setModule($moduleModel);

      Reference to undeclared property \Settings_SMSNotifier_Record_Model->module
      Open

              $this->module = $moduleModel;

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

          public static function getCleanInstance(?string $provider = null)

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

              return (new \App\Db\Query())->from('w_#__sms_user')->where(['status' => 1])->all();

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

                      $db->createCommand()->update($baseTable, ['isactive' => 0], ['<>', $baseTableIndex, (int) $this->getId()])->execute();

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

      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::createCommand
      Open

                  $result = $db->createCommand()->delete($table, [$index => $recordId])->execute();

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

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

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

      class Settings_SMSNotifier_Record_Model extends Settings_Vtiger_Record_Model

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

          public function clearCache($id)

      ShortVariable

      Since: 0.2

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

      Example

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

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

      The class Settings_SMSNotifier_Record_Model is not named in CamelCase.
      Open

      class Settings_SMSNotifier_Record_Model extends Settings_Vtiger_Record_Model
      {
          /** @var array Record changes */
          protected $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('admin');

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

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

      ShortVariable

      Since: 0.2

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

      Example

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

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

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

          public static function getInstanceById($id)

      ShortVariable

      Since: 0.2

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

      Example

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

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

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

           *

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

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

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

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

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

      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

              return $result;

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

          }

      Line exceeds 120 characters; contains 124 characters
      Open

                      $db->createCommand()->update($baseTable, $tablesData, [$baseTableIndex => (int) $this->getId()])->execute();

      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

           * @return mixed

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

          public function getDisplayValue(string $name)

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

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

              if ($tablesData) {

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

                      $db->createCommand()->update($baseTable, $tablesData, [$baseTableIndex => (int) $this->getId()])->execute();

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

           * Function to get Name of this record instance.

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

           * @return Settings_SMSNotifier_Module_Model $moduleModel

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

          /**

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

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

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

              foreach ($recordLinks as $recordLink) {

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

          {

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

                  $result = true;

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

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

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

           * @return <Integer> Id

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

           * Function to get module of this record instance.

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

           */

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

              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

          }

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

                      'linkurl' => $this->getEditViewUrl() . '&record=' . $this->getId(),

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

                      'linklabel' => 'LBL_DELETE_RECORD',

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

          }

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

                  $moduleName = $this->getModule()->getName();

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

                  return empty($this->get($name)) ? \App\Language::translate('FL_INACTIVE', "Settings:$moduleName") : \App\Language::translate('FL_ACTIVE');

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

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

           * @param Settings_SMSNotifier_Module_Model $moduleModel

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

           * @return string Url

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

           *

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

          /**

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

              $transaction = $db->beginTransaction();

      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

           */

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

              if ('isactive' === $name) {

      Line exceeds 120 characters; contains 150 characters
      Open

                  return empty($this->get($name)) ? \App\Language::translate('FL_INACTIVE', "Settings:$moduleName") : \App\Language::translate('FL_ACTIVE');

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

                  $transaction->commit();

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

                  \App\Log::error($ex->__toString());

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

           * @return Settings_SMSNotifier_Record_Model this record

      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

              return \App\Integrations\SMSProvider::getProviderByName($this->get('providertype'))->getEditViewUrl() . '&record=' . $this->getId();

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

                  $this->saveToDb();

      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->getId()) {

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

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

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

                  if (!empty($tablesData['isactive'])) {

      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

                      'linktype' => 'LISTVIEWRECORD',

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

                  ],

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

           */

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

              $fields = array_flip(['providertype', 'isactive', 'api_key', 'parameters', 'name']);

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

                  $baseTable = $this->getModule()->baseTable;

      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

                      $db->createCommand()->update($baseTable, ['isactive' => 0], ['<>', $baseTableIndex, (int) $this->getId()])->execute();

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

          private $editFields = ['name', 'isactive'];

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

          }

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

          }

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

           *

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

           */

      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

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

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

                      'modalView' => true,

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

           * Save data to the database.

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

          public function getRecordLinks(): array

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

                      'linklabel' => 'LBL_EDIT_RECORD',

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

                      'linkurl' => 'javascript:Settings_Vtiger_List_Js.deleteById(' . $this->getId() . ');',

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

              return $links;

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

           * Function to getDisplay value of every field.

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

           *

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

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

          public function saveToDb()

      Line exceeds 120 characters; contains 151 characters
      Open

              $tablesData = $this->getId() ? array_intersect_key($this->getData(), $this->changes, $fields) : array_intersect_key($this->getData(), $fields);

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

                  $baseTableIndex = $this->getModule()->baseIndex;

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

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

          public function getEditViewUrl()

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

                      'linktype' => 'LISTVIEWRECORD',

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

                  ],

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

                  [

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

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

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

          public function save()

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

              } catch (\Throwable $ex) {

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

                  $transaction->rollBack();

      Line exceeds 120 characters; contains 134 characters
      Open

                      $db->createCommand()->update($baseTable, ['isactive' => 0], ['<>', $baseTableIndex, (int) $this->getId()])->execute();

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

          /** @var array Record 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

           * Function to get Edit view url.

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

          /**

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

                      $db->createCommand()->insert($baseTable, $tablesData)->execute();

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

          protected $changes = [];

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

           * Function to get Id of this record instance.

      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

          }

      Line exceeds 120 characters; contains 140 characters
      Open

              return \App\Integrations\SMSProvider::getProviderByName($this->get('providertype'))->getEditViewUrl() . '&record=' . $this->getId();

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

              $recordLinks = [

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

              ];

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

              $links = [];

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

              }

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

              $result = false;

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

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

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

              $tablesData = $this->getId() ? array_intersect_key($this->getData(), $this->changes, $fields) : array_intersect_key($this->getData(), $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

          public function getModule()

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

           * Function to set module instance to this record instance.

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

           *

      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 \App\Purifier::encodeHtml($this->get($name));

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

                  throw $ex;

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

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

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

                          $parameters = $this->getParameters();

      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->isNew = false;

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

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

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

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

                      $params['label'] = 'FL_STATUS';

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

                          $value = App\Encryption::getInstance()->encrypt($value);

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

                          $this->set($fieldName, $value);

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

                      $fieldModel->getUITypeModel()->validate($value, true);

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

           *

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

          {

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

           *

      Line exceeds 120 characters; contains 176 characters
      Open

              if ($this->getId() && !\in_array($key, ['id']) && (\array_key_exists($key, $this->value) && $this->value[$key] != $value) && !\array_key_exists($key, $this->changes)) {

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

              return 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

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

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

                      $params['uitype'] = 16;

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

                      $params['label'] = 'FL_PROVIDER';

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

                      $params['fieldvalue'] = $this->getValueByField($name);

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

                      break;

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

              }

      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 setDataFromRequest(App\Request $request)

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

                          $parameters[$fieldName] = $value;

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

              \App\Cache::staticDelete(__CLASS__, $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

           * @return \self

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

                  ->where([$instance->getModule()->getBaseIndex() => $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

              $recordModel->set('providertype', $provider);

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

           *

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

              $params = ['uitype' => 1, 'column' => $name, 'name' => $name, 'displaytype' => 1, 'typeofdata' => 'V~M', 'presence' => 0, 'isEditableReadOnly' => false];

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

                      $params['purifyType'] = \App\Purifier::INTEGER;

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

           *

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

           * @param string $fieldName

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

           *

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

                      $value = $fieldModel->getUITypeModel()->getDBValue($value);

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

                          $this->set('parameters', \App\Json::encode($parameters));

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

              if ($this->getId() && !\in_array($key, ['id']) && (\array_key_exists($key, $this->value) && $this->value[$key] != $value) && !\array_key_exists($key, $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

                      $params['fieldvalue'] = $this->getValueByField($name);

      Line exceeds 120 characters; contains 130 characters
      Open

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

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

                      }

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

                  case 'isactive':

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

              return $fieldName ? ($this->changes[$fieldName] ?? null) : $this->changes;

      Line exceeds 120 characters; contains 157 characters
      Open

                      $value = $request->isEmpty($fieldName) && !$fieldModel->isMandatory() ? '' : $request->getByType($fieldName, $fieldModel->get('purifyType'));

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

                      if (\in_array($fieldName, ['id', 'providertype', 'isactive', 'api_key', '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

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

      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

          /**

      Line exceeds 120 characters; contains 161 characters
      Open

              $params = ['uitype' => 1, 'column' => $name, 'name' => $name, 'displaytype' => 1, 'typeofdata' => 'V~M', 'presence' => 0, 'isEditableReadOnly' => false];

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

              switch ($name) {

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

          }

      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 App\Request $request

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

          }

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

                      $value = '****';

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

           * Function to get clean record instance by using moduleName.

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

           * @param string $name

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

                      $value = $request->isEmpty($fieldName) && !$fieldModel->isMandatory() ? '' : $request->getByType($fieldName, $fieldModel->get('purifyType'));

      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

          public function anonymize(array $data): 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

           * @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 = (new App\Db\Query())

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

                  ->from($instance->getModule()->getBaseTable())

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

              $moduleModel = Settings_Vtiger_Module_Model::getInstance('Settings:SMSNotifier');

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

                      $params['purifyType'] = \App\Purifier::STANDARD;

      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

                  $this->changes[$key] = $this->get($key);

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

           * Data anonymization.

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

                  if ('api_key' === $key || 'pwd' === $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

           * @param string $provider

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

           * Get pervious value by field.

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

           * @return mixed

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

              foreach ($this->getEditFields() as $fieldName => $fieldModel) {

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

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

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

           * @param mixed  $value

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

          }

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

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

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

              \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

           * 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

           * @return \Vtiger_Field_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

                      $params['picklistValues'] = [1 => \App\Language::translate('FL_ACTIVE'), 0 => \App\Language::translate('FL_INACTIVE')];

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

           * Sets data from request.

      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

          public static function getCleanInstance(?string $provider = 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

              $moduleName = $this->getModule()->getName(true);

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

           *

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

           */

      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

           *

      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

              $instance = self::getCleanInstance();

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

              $instance->setData($data);

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

              $recordModel = new self();

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

              $recordModel->isNew = true;

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

                      $params['displaytype'] = 2;

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

                      $params['uitype'] = 16;

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

          public function getPreviousValue(string $fieldName = '')

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

           */

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

           */

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

           * @param string $qualifiedModuleName

      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 set the value for a given key.

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

          /**

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

          {

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

              return $recordModel->setModule($moduleModel);

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

          public function getFieldInstanceByName($name)

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

                      $params['picklistValues'] = [];

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

                      foreach (\App\Integrations\SMSProvider::getProviders() as $provider) {

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

           */

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

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

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

                  $fields[$fieldName] = $this->getFieldInstanceByName($fieldName);

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

           */

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

           *

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

           * @return bool

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

                  case 'name':

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

           * Get parameter value by 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

              return !empty($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

                      if ('api_key' === $fieldName) {

      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

           * Clear cache.

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

           * @param string $key

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

              foreach ($data as $key => &$value) {

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

           *

      Line exceeds 120 characters; contains 135 characters
      Open

                      $params['picklistValues'] = [1 => \App\Language::translate('FL_ACTIVE'), 0 => \App\Language::translate('FL_INACTIVE')];

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

                      $params['purifyType'] = \App\Purifier::TEXT;

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

                      $params['maximumlength'] = 50;

      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 value by name.

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

           * @param string $fieldName

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

              $recordId = $this->getId();

      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

          {

      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_key_exists($fieldName, $this->value) ? $this->value[$fieldName] : $this->getParameter($fieldName);

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

          public function getServiveUsers(): array

      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

          }

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

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

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

                  $this->clearCache($recordId);

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

                      $params['uitype'] = 1;

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

                      $params['label'] = 'FL_NAME';

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

              $fields = [];

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

          public function getParameters(): 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

           * @return mixed

      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 = $db->createCommand()->delete($table, [$index => $recordId])->execute();

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

           * Get webservice users.

      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

           * @param string $fieldName

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

          public function getValueByField(string $fieldName)

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

                  $index = $this->getModule()->getBaseIndex();

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

           * @return string

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

          public function getParameter(string $fieldName): 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

                      $params['fieldvalue'] = $this->getValueByField($name);

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

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

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

              return $fields;

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

              return $this->get('parameters') ? \App\Json::decode($this->get('parameters')) : [];

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

           */

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

          {

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

              return $this->getParameters()[$fieldName] ?? '';

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

           */

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

              }

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

                  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

          {

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

              foreach ($provider->getEditFields() as $fieldName => $fieldModel) {

      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 Vtiger_Field_Model[]

      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

              $provider = \App\Integrations\SMSProvider::getProviderByName($this->get('providertype'));

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

                  $fields[$fieldName] = $fieldModel;

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

      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

          }

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

                  $table = $this->getModule()->getBaseTable();

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

              return Settings_Vtiger_Field_Model::init($moduleName, $params);

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

           * Get parameters.

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

              return (new \App\Db\Query())->from('w_#__sms_user')->where(['status' => 1])->all();

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

          }

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

           */

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

              if ($recordId) {

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

          public function delete()

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

      class Settings_SMSNotifier_Record_Model extends Settings_Vtiger_Record_Model

      There are no issues that match your filters.

      Category
      Status