YetiForceCompany/YetiForceCRM

View on GitHub
modules/Vtiger/models/Inventory.php

Summary

Maintainability
F
3 days
Test Coverage
F
41%

File Inventory.php has 510 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

/**
 * Basic Inventory Model Class.
 *
Severity: Major
Found in modules/Vtiger/models/Inventory.php - About 1 day to fix

    Vtiger_Inventory_Model has 35 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Vtiger_Inventory_Model
    {
        /**
         * Field configuration table postfix.
         */
    Severity: Minor
    Found in modules/Vtiger/models/Inventory.php - About 4 hrs to fix

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

      class Vtiger_Inventory_Model
      {
          /**
           * Field configuration table postfix.
           */
      Severity: Minor
      Found in modules/Vtiger/models/Inventory.php by phpmd

      Method createInventoryTables has 62 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function createInventoryTables()
          {
              $db = \App\Db::getInstance();
              $importer = new \App\Db\Importers\Base();
              $focus = CRMEntity::getInstance($this->getModuleName());
      Severity: Major
      Found in modules/Vtiger/models/Inventory.php - About 2 hrs to fix

        Function getFieldsTypes has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            public function getFieldsTypes(): array
            {
                $moduleName = $this->getModuleName();
                if (\App\Cache::has(__METHOD__, $moduleName)) {
                    $inventoryTypes = \App\Cache::get(__METHOD__, $moduleName);
        Severity: Minor
        Found in modules/Vtiger/models/Inventory.php - About 2 hrs to fix

        Cognitive Complexity

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

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

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

        Further reading

        Function loadRowData has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
        Open

            public function loadRowData(int $recordId, array $params = []): array
            {
                $recordModel = Vtiger_Record_Model::getInstanceById($recordId);
                $recordModuleName = $recordModel->getModuleName();
                $data = [
        Severity: Minor
        Found in modules/Vtiger/models/Inventory.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 deleteField has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            public function deleteField(string $fieldName): bool
            {
                $db = \App\Db::getInstance();
                $dbCommand = $db->createCommand();
                $transaction = $db->beginTransaction();
        Severity: Minor
        Found in modules/Vtiger/models/Inventory.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 saveField has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function saveField(Vtiger_Basic_InventoryField $fieldModel): bool
            {
                $db = \App\Db::getInstance();
                $tableName = $this->getTableName();
                if (!$fieldModel->has('sequence')) {
        Severity: Minor
        Found in modules/Vtiger/models/Inventory.php - About 1 hr to fix

          Method deleteField has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function deleteField(string $fieldName): bool
              {
                  $db = \App\Db::getInstance();
                  $dbCommand = $db->createCommand();
                  $transaction = $db->beginTransaction();
          Severity: Minor
          Found in modules/Vtiger/models/Inventory.php - About 1 hr to fix

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

                public function loadRowData(int $recordId, array $params = []): array
                {
                    $recordModel = Vtiger_Record_Model::getInstanceById($recordId);
                    $recordModuleName = $recordModel->getModuleName();
                    $data = [
            Severity: Minor
            Found in modules/Vtiger/models/Inventory.php - About 1 hr to fix

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

                  public function saveField(Vtiger_Basic_InventoryField $fieldModel): bool
                  {
                      $db = \App\Db::getInstance();
                      $tableName = $this->getTableName();
                      if (!$fieldModel->has('sequence')) {
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php - About 45 mins to fix

              Cognitive Complexity

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

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

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

              Further reading

              Function getInventoryDataById has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static function getInventoryDataById(int $recordId, string $moduleName, ?Vtiger_Paging_Model $pagingModel = null): array
                  {
                      $inventory = self::getInstance($moduleName);
                      $query = (new \App\Db\Query())->from($inventory->getTableName(self::TABLE_POSTFIX_DATA))->indexBy('id')->where(['crmid' => $recordId]);
                      if ($inventory->isField('seq')) {
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php - About 35 mins to fix

              Cognitive Complexity

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

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

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

              Further reading

              Function getDiscountsConfig has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  public static function getDiscountsConfig(string $key = '')
                  {
                      if (\App\Cache::has('Inventory', 'DiscountConfiguration')) {
                          $config = \App\Cache::get('Inventory', 'DiscountConfiguration');
                      } else {
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php - About 35 mins to fix

              Cognitive Complexity

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

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

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

              Further reading

              Function getCustomAutoComplete has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function getCustomAutoComplete(string $sourceFieldName, Vtiger_Record_Model $recordModel)
                  {
                      $values = [];
                      $inventoryMap = App\Config::module($this->getModuleName(), 'INVENTORY_ON_SELECT_AUTO_COMPLETE');
                      if ($inventoryMap) {
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php - About 35 mins to fix

              Cognitive Complexity

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

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

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

              Further reading

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

                  public function getFieldsForView(string $view): array
                  {
                      $fieldList = [];
                      switch ($view) {
                          case 'DetailPreview':
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.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 createInventoryTables has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function createInventoryTables()
                  {
                      $db = \App\Db::getInstance();
                      $importer = new \App\Db\Importers\Base();
                      $focus = CRMEntity::getInstance($this->getModuleName());
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.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 loadRowData() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10.
              Open

                  public function loadRowData(int $recordId, array $params = []): array
                  {
                      $recordModel = Vtiger_Record_Model::getInstanceById($recordId);
                      $recordModuleName = $recordModel->getModuleName();
                      $data = [
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              CyclomaticComplexity

              Since: 0.1

              Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

              Example

              // Cyclomatic Complexity = 11
              class Foo {
              1   public function example() {
              2       if ($a == $b) {
              3           if ($a1 == $b1) {
                              fiddle();
              4           } elseif ($a2 == $b2) {
                              fiddle();
                          } else {
                              fiddle();
                          }
              5       } elseif ($c == $d) {
              6           while ($c == $d) {
                              fiddle();
                          }
              7        } elseif ($e == $f) {
              8           for ($n = 0; $n < $h; $n++) {
                              fiddle();
                          }
                      } else {
                          switch ($z) {
              9               case 1:
                                  fiddle();
                                  break;
              10              case 2:
                                  fiddle();
                                  break;
              11              case 3:
                                  fiddle();
                                  break;
                              default:
                                  fiddle();
                                  break;
                          }
                      }
                  }
              }

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

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

                  public function getFieldsTypes(): array
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by sonar-php

              Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

              See

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

              class Vtiger_Inventory_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 Vtiger_Inventory_Model has a coupling between objects value of 23. Consider to reduce the number of dependencies under 13.
              Open

              class Vtiger_Inventory_Model
              {
                  /**
                   * Field configuration table postfix.
                   */
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              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 '502', column '23').
              Open

                          $dataReader = (new \App\Db\Query())->from($this->getTableName(self::TABLE_POSTFIX_MAP))->createCommand()->query();
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              MissingImport

              Since: 2.7.0

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

              Example

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

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

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

                      $query = (new \App\Db\Query())->from($inventory->getTableName(self::TABLE_POSTFIX_DATA))->indexBy('id')->where(['crmid' => $recordId]);
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              MissingImport

              Since: 2.7.0

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

              Example

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

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

              Missing class import via use statement (line '435', column '81').
              Open

                      return $db->createCommand()->update($this->getTableName(), ['sequence' => new \yii\db\Expression($case)], ['id' => $sequenceList])->execute();
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              MissingImport

              Since: 2.7.0

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

              Example

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

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

              Missing class import via use statement (line '619', column '21').
              Open

                      $discounts = (new App\Db\Query())->from('a_#__discounts_global')->where(['status' => 0])
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              MissingImport

              Since: 2.7.0

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

              Example

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

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

              Missing class import via use statement (line '777', column '15').
              Open

                      $base = new \App\Db\Importer();
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              MissingImport

              Since: 2.7.0

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

              Example

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

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

              Missing class import via use statement (line '460', column '18').
              Open

                              foreach (new DirectoryIterator($fieldPath) as $object) {
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              MissingImport

              Since: 2.7.0

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

              Example

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

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

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

                      $defaultTax = (new App\Db\Query())->from('a_#__taxes_global')->where(['status' => 0])->andWhere(['default' => 1])
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              MissingImport

              Since: 2.7.0

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

              Example

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

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

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

                          $row = (new \App\Db\Query())->from($this->getTableName())->where(['id' => $fieldId])->one();
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              MissingImport

              Since: 2.7.0

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

              Example

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

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

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

                          $dataReader = (new \App\Db\Query())->from('a_#__discounts_config')->createCommand(\App\Db::getInstance('admin'))->query();
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              MissingImport

              Since: 2.7.0

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

              Example

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

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

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

                          $dataReader = (new \App\Db\Query())->from($this->getTableName())->indexBy('columnname')
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              MissingImport

              Since: 2.7.0

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

              Example

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

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

              Missing class import via use statement (line '350', column '15').
              Open

                          $id = (new \App\Db\Query())->from($tableName)->where(['invtype' => $fieldModel->getType()])->max('id') + 1;
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              MissingImport

              Since: 2.7.0

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

              Example

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

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

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

                      $dataReader = (new App\Db\Query())->from('a_#__taxes_config')->createCommand(App\Db::getInstance('admin'))->query();
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              MissingImport

              Since: 2.7.0

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

              Example

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

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

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

                      $taxes = (new App\Db\Query())->from('a_#__taxes_global')->where(['status' => 0])
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              MissingImport

              Since: 2.7.0

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

              Example

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

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

              Missing class import via use statement (line '728', column '19').
              Open

                      $importer = new \App\Db\Importers\Base();
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              MissingImport

              Since: 2.7.0

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

              Example

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

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

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

                          $instance = \App\Cache::staticGet(__METHOD__, $moduleName);
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

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

                      } else {
                          $modelClassName = Vtiger_Loader::getComponentClassName('Model', 'Inventory', $moduleName);
                          $instance = new $modelClassName();
                          $instance->setModuleName($moduleName);
                          \App\Cache::staticSave(__METHOD__, $moduleName, $instance);
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              ElseExpression

              Since: 1.4.0

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

              Example

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

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

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

                  public function deleteField(string $fieldName): bool
                  {
                      $db = \App\Db::getInstance();
                      $dbCommand = $db->createCommand();
                      $transaction = $db->beginTransaction();
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              IfStatementAssignment

              Since: 2.7.0

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

              Example

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

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

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

                      if (\App\Cache::has('Inventory', 'TaxConfiguration')) {
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

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

                      if (\App\Cache::has('Inventory', 'DefaultTax')) {
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

              Avoid using static access to class 'Vtiger_Record_Model' in method 'getAccountDiscount'.
              Open

                          $accountRecordModel = Vtiger_Record_Model::getInstanceById($relatedRecord);
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

              Avoid using static access to class 'Vtiger_Taxes_UIType' in method 'getAccountTax'.
              Open

                          $accountTaxes = Vtiger_Taxes_UIType::getValues($accountRecordModel->get($taxField->getName()));
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

              Avoid using static access to class 'App\Config' in method 'createInventoryTables'.
              Open

                      $base->dieOnError = App\Config::debug('SQL_DIE_ON_ERROR');
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

              Avoid using static access to class 'Vtiger_Loader' in method 'getInstance'.
              Open

                          $modelClassName = Vtiger_Loader::getComponentClassName('Model', 'Inventory', $moduleName);
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

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

                      if (\App\Cache::staticHas(__METHOD__, $fieldId)) {
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

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

                          \App\Log::error($ex->__toString());
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

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

                      $db = \App\Db::getInstance();
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

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

                          return \App\Cache::get('Inventory', 'Discounts');
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

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

                  public function loadRowData(int $recordId, array $params = []): array
                  {
                      $recordModel = Vtiger_Record_Model::getInstanceById($recordId);
                      $recordModuleName = $recordModel->getModuleName();
                      $data = [
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              IfStatementAssignment

              Since: 2.7.0

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

              Example

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

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

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

                      if (\App\Cache::staticHas(__METHOD__, $moduleName)) {
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

              Avoid using static access to class 'vtlib\Utils' in method 'saveField'.
              Open

                                  vtlib\Utils::addColumn($table, $column, $criteria);
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

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

                          App\Cache::save(__METHOD__, $moduleName, $fields);
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

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

                      \App\Cache::save('Inventory', 'Taxes', $taxes, \App\Cache::LONG);
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

              Avoid using static access to class '\App\Record' in method 'getAccountTax'.
              Open

                      if (!empty($relatedRecord) && \App\Record::isExists($relatedRecord, $sourceModule) && ($taxField = current(Vtiger_Module_Model::getInstance($sourceModule)->getFieldsByUiType(303))) && $taxField->isActiveField()) {
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

              Avoid using static access to class '\App\Fields\Currency' in method 'loadRowData'.
              Open

              }
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

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

                      if (\App\Cache::has(__METHOD__, $moduleName)) {
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

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

                      if (\App\Cache::has(__METHOD__, $moduleName)) {
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

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

                  public function getAccountTax($relatedRecord)
                  {
                      $sourceModule = 'Accounts';
                      $recordName = '';
                      $accountTaxes = [];
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              IfStatementAssignment

              Since: 2.7.0

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

              Example

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

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

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

                  public function loadRowData(int $recordId, array $params = []): array
                  {
                      $recordModel = Vtiger_Record_Model::getInstanceById($recordId);
                      $recordModuleName = $recordModel->getModuleName();
                      $data = [
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              IfStatementAssignment

              Since: 2.7.0

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

              Example

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

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

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

                      \App\Cache::save('Inventory', 'TaxConfiguration', $config, \App\Cache::LONG);
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

              Avoid using static access to class 'CRMEntity' in method 'createInventoryTables'.
              Open

                      $focus = CRMEntity::getInstance($this->getModuleName());
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

              Avoid using static access to class 'Vtiger_Basic_InventoryField' in method 'getFields'.
              Open

                              $fieldModel = Vtiger_Basic_InventoryField::getInstance($this->moduleName, $row['invtype']);
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

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

                          } else {
                              $pagingModel->set('nextPageExists', false);
                          }
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              ElseExpression

              Since: 1.4.0

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

              Example

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

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

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

                  public function getFieldsTypes(): array
                  {
                      $moduleName = $this->getModuleName();
                      if (\App\Cache::has(__METHOD__, $moduleName)) {
                          $inventoryTypes = \App\Cache::get(__METHOD__, $moduleName);
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              IfStatementAssignment

              Since: 2.7.0

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

              Example

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

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

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

                          ->createCommand(App\Db::getInstance('admin'))->queryAllByGroup(1);
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

              Avoid using static access to class 'Vtiger_Record_Model' in method 'getAccountTax'.
              Open

                          $accountRecordModel = Vtiger_Record_Model::getInstanceById($relatedRecord, $sourceModule);
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

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

                          \App\Cache::save(__METHOD__, $moduleName, $inventoryTypes);
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

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

                      if (\App\Cache::has('Inventory', 'Taxes')) {
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

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

                          return \App\Cache::get('Inventory', 'DefaultTax');
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

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

                          \App\Cache::staticSave(__METHOD__, $fieldId, $fieldModel);
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

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

                      $db = \App\Db::getInstance();
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

              Avoid using static access to class 'vtlib\Utils' in method 'saveField'.
              Open

                              vtlib\Utils::addColumn($table, $fieldModel->getColumnName(), $fieldModel->getDBType());
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

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

                          \App\Log::error($ex->__toString());
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

              Avoid using static access to class 'Vtiger_Basic_InventoryField' in method 'getFieldsTypes'.
              Open

                                      $inventoryTypes[$type] = Vtiger_Basic_InventoryField::getInstance($moduleName, $type);
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

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

                      } else {
                          $fields = [];
                          $dataReader = (new \App\Db\Query())->from($this->getTableName(self::TABLE_POSTFIX_MAP))->createCommand()->query();
                          while ($row = $dataReader->read()) {
                              $fields[$row['module']][$row['tofield']] = $row;
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              ElseExpression

              Since: 1.4.0

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

              Example

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

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

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

                      if (\App\Cache::has('Inventory', 'DiscountConfiguration')) {
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

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

                          $dataReader = (new \App\Db\Query())->from('a_#__discounts_config')->createCommand(\App\Db::getInstance('admin'))->query();
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

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

                      if (\App\Cache::has('Inventory', 'Discounts')) {
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

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

                          return \App\Cache::get('Inventory', 'TaxConfiguration');
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

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

                      \App\Cache::save('Inventory', 'DefaultTax', $defaultTax, \App\Cache::LONG);
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

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

                          } else {
                              $result = $db->createCommand()->update($tableName, $data, ['id' => $fieldModel->get('id')])->execute();
                          }
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              ElseExpression

              Since: 1.4.0

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

              Example

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

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

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

                      \App\Cache::save('Inventory', 'Discounts', $discounts, \App\Cache::LONG);
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

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

                      $db = \App\Db::getInstance();
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

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

                  public function loadRowData(int $recordId, array $params = []): array
                  {
                      $recordModel = Vtiger_Record_Model::getInstanceById($recordId);
                      $recordModuleName = $recordModel->getModuleName();
                      $data = [
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              IfStatementAssignment

              Since: 2.7.0

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

              Example

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

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

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

                  public function loadRowData(int $recordId, array $params = []): array
                  {
                      $recordModel = Vtiger_Record_Model::getInstanceById($recordId);
                      $recordModuleName = $recordModel->getModuleName();
                      $data = [
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              IfStatementAssignment

              Since: 2.7.0

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

              Example

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

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

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

                          $inventoryTypes = \App\Cache::get(__METHOD__, $moduleName);
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

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

                          $fields = \App\Cache::get(__METHOD__, $moduleName);
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

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

                          \App\Cache::save('Inventory', 'DiscountConfiguration', $config, \App\Cache::LONG);
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

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

                          ->createCommand(App\Db::getInstance('admin'))->queryAllByGroup(1);
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

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

                          \App\Cache::staticSave(__METHOD__, $moduleName, $instance);
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

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

                      } else {
                          $fieldPaths = ["modules/$moduleName/inventoryfields/"];
                          if ('Vtiger' !== $moduleName) {
                              $fieldPaths[] = 'modules/Vtiger/inventoryfields/';
                          }
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              ElseExpression

              Since: 1.4.0

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

              Example

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

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

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

                      } else {
                          $config = [];
                          $dataReader = (new \App\Db\Query())->from('a_#__discounts_config')->createCommand(\App\Db::getInstance('admin'))->query();
                          while ($row = $dataReader->read()) {
                              $value = $row['value'];
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              ElseExpression

              Since: 1.4.0

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

              Example

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

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

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

                      $dataReader = (new App\Db\Query())->from('a_#__taxes_config')->createCommand(App\Db::getInstance('admin'))->query();
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

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

                          return \App\Cache::get('Inventory', 'Taxes');
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

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

                      } else {
                          $row = (new \App\Db\Query())->from($this->getTableName())->where(['id' => $fieldId])->one();
                          if ($row) {
                              $fieldModel = $this->getFieldCleanInstance($row['invtype']);
                              $this->setFieldData($fieldModel, $row);
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              ElseExpression

              Since: 1.4.0

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

              Example

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

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

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

                      $db = \App\Db::getInstance();
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

              Avoid using static access to class 'App\Config' in method 'getCustomAutoComplete'.
              Open

                      $inventoryMap = App\Config::module($this->getModuleName(), 'INVENTORY_ON_SELECT_AUTO_COMPLETE');
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

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

                          $fieldModel = \App\Cache::staticGet(__METHOD__, $fieldId);
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

              Avoid using static access to class '\Vtiger_Basic_InventoryField' in method 'getFieldCleanInstance'.
              Open

                      return \Vtiger_Basic_InventoryField::getInstance($this->getModuleName(), $type);
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

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

                          $config = \App\Cache::get('Inventory', 'DiscountConfiguration');
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

              Avoid using static access to class 'Vtiger_Record_Model' in method 'loadRowData'.
              Open

                      $recordModel = Vtiger_Record_Model::getInstanceById($recordId);
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              StaticAccess

              Since: 1.4.0

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

              Example

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

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

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

                              $fields[$row['module']][$row['tofield']] = $row;
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by sonar-php

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

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

              Noncompliant Code Example

              With the default threshold of 3:

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

              Compliant Solution

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

              Exceptions

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

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

                              ->orderBy(['block' => SORT_ASC, 'sequence' => SORT_ASC])->createCommand()->query();
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by sonar-php

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

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

              Noncompliant Code Example

              With the default threshold of 3:

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

              Compliant Solution

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

              Exceptions

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

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

                          $dataReader = (new \App\Db\Query())->from($this->getTableName())->indexBy('columnname')
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by sonar-php

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

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

              Noncompliant Code Example

              With the default threshold of 3:

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

              Compliant Solution

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

              Exceptions

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

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

                          ->set('params', $row['params'])
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by sonar-php

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

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

              Noncompliant Code Example

              With the default threshold of 3:

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

              Compliant Solution

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

              Exceptions

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

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

                      if (\App\Cache::has('Inventory', 'DefaultTax')) {
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by sonar-php

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

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

              Noncompliant Code Example

              With the default threshold of 3:

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

              Compliant Solution

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

              Exceptions

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

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

                              'charset' => 'utf8',
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by sonar-php

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

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

              Noncompliant Code Example

              With the default threshold of 3:

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

              Compliant Solution

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

              Exceptions

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

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

                              $fields[$row['module']][$row['tofield']] = $row;
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by sonar-php

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

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

              Noncompliant Code Example

              With the default threshold of 3:

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

              Compliant Solution

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

              Exceptions

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

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

                              'columns' => [
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by sonar-php

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

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

              Noncompliant Code Example

              With the default threshold of 3:

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

              Compliant Solution

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

              Exceptions

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

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

                              $fieldModel = Vtiger_Basic_InventoryField::getInstance($this->moduleName, $row['invtype']);
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by sonar-php

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

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

              Noncompliant Code Example

              With the default threshold of 3:

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

              Compliant Solution

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

              Exceptions

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

              Define a constant instead of duplicating this literal "Inventory" 16 times.
              Open

                          $modelClassName = Vtiger_Loader::getComponentClassName('Model', 'Inventory', $moduleName);
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by sonar-php

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

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

              Noncompliant Code Example

              With the default threshold of 3:

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

              Compliant Solution

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

              Exceptions

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

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

                                  'field' => $importer->stringType(50)->notNull(),
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by sonar-php

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

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

              Noncompliant Code Example

              With the default threshold of 3:

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

              Compliant Solution

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

              Exceptions

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

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

                          ->set('label', $row['label'])
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by sonar-php

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

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

              Noncompliant Code Example

              With the default threshold of 3:

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

              Compliant Solution

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

              Exceptions

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

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

                      if (\App\Cache::has('Inventory', 'TaxConfiguration')) {
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by sonar-php

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

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

              Noncompliant Code Example

              With the default threshold of 3:

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

              Compliant Solution

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

              Exceptions

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

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

                              'foreignKey' => [
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by sonar-php

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

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

              Noncompliant Code Example

              With the default threshold of 3:

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

              Compliant Solution

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

              Exceptions

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

              Rename "$tableName" which has the same name as the field declared at line 39.
              Open

                      $tableName = $this->getTableName();

              Shadowing fields with a local variable is a bad practice that reduces code readability: it makes it confusing to know whether the field or the variable is being used.

              Noncompliant Code Example

              class Foo {
                public $myField;
              
                public function doSomething() {
                  $myField = 0;
                  ...
                }
              }
              

              See

              Rename "$moduleName" which has the same name as the field declared at line 31.
              Open

                      $moduleName = $this->getModuleName();

              Shadowing fields with a local variable is a bad practice that reduces code readability: it makes it confusing to know whether the field or the variable is being used.

              Noncompliant Code Example

              class Foo {
                public $myField;
              
                public function doSomething() {
                  $myField = 0;
                  ...
                }
              }
              

              See

              Rename "$fields" which has the same name as the field declared at line 35.
              Open

                          $fields = \App\Cache::get(__METHOD__, $moduleName);

              Shadowing fields with a local variable is a bad practice that reduces code readability: it makes it confusing to know whether the field or the variable is being used.

              Noncompliant Code Example

              class Foo {
                public $myField;
              
                public function doSomething() {
                  $myField = 0;
                  ...
                }
              }
              

              See

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

                      $query = (new \App\Db\Query())->from($inventory->getTableName(self::TABLE_POSTFIX_DATA))->indexBy('id')->where(['crmid' => $recordId]);
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by sonar-php

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

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

              Noncompliant Code Example

              With the default threshold of 3:

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

              Compliant Solution

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

              Exceptions

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

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

                      if (\App\Cache::has('Inventory', 'DiscountConfiguration')) {
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by sonar-php

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

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

              Noncompliant Code Example

              With the default threshold of 3:

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

              Compliant Solution

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

              Exceptions

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

              Rename "$moduleName" which has the same name as the field declared at line 31.
              Open

                      $moduleName = $this->getModuleName();

              Shadowing fields with a local variable is a bad practice that reduces code readability: it makes it confusing to know whether the field or the variable is being used.

              Noncompliant Code Example

              class Foo {
                public $myField;
              
                public function doSomething() {
                  $myField = 0;
                  ...
                }
              }
              

              See

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

                          ->set('presence', (int) $row['presence'])
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by sonar-php

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

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

              Noncompliant Code Example

              With the default threshold of 3:

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

              Compliant Solution

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

              Exceptions

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

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

                          $dataReader = (new \App\Db\Query())->from('a_#__discounts_config')->createCommand(\App\Db::getInstance('admin'))->query();
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by sonar-php

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

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

              Noncompliant Code Example

              With the default threshold of 3:

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

              Compliant Solution

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

              Exceptions

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

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

                              'engine' => 'InnoDB',
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by sonar-php

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

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

              Noncompliant Code Example

              With the default threshold of 3:

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

              Compliant Solution

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

              Exceptions

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

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

                      if (\App\Cache::has('Inventory', 'Discounts')) {
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by sonar-php

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

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

              Noncompliant Code Example

              With the default threshold of 3:

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

              Compliant Solution

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

              Exceptions

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

              Define a constant instead of duplicating this literal "sequence" 8 times.
              Open

                              ->orderBy(['block' => SORT_ASC, 'sequence' => SORT_ASC])->createCommand()->query();
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by sonar-php

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

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

              Noncompliant Code Example

              With the default threshold of 3:

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

              Compliant Solution

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

              Exceptions

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

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

                      $discounts = (new App\Db\Query())->from('a_#__discounts_global')->where(['status' => 0])
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by sonar-php

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

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

              Noncompliant Code Example

              With the default threshold of 3:

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

              Compliant Solution

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

              Exceptions

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

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

                      if (\App\Cache::has('Inventory', 'Taxes')) {
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by sonar-php

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

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

              Noncompliant Code Example

              With the default threshold of 3:

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

              Compliant Solution

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

              Exceptions

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

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

                              'engine' => 'InnoDB',
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by sonar-php

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

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

              Noncompliant Code Example

              With the default threshold of 3:

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

              Compliant Solution

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

              Exceptions

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

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

                              if (\in_array($row['param'], ['discounts'])) {
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by sonar-php

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

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

              Noncompliant Code Example

              With the default threshold of 3:

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

              Compliant Solution

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

              Exceptions

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

              Reference to undeclared property \CRMEntity->table_name
              Open

                          $this->tableName = CRMEntity::getInstance($this->moduleName)->table_name;
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phan

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

                      $dataReader = (new App\Db\Query())->from('a_#__taxes_config')->createCommand(App\Db::getInstance('admin'))->query();
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by phan

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

                      $defaultTax = (new App\Db\Query())->from('a_#__taxes_global')->where(['status' => 0])->andWhere(['default' => 1])
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by phan

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

                          $fieldModel = \App\Cache::staticGet(__METHOD__, $fieldId);
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phan

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

                          \App\Cache::staticSave(__METHOD__, $fieldId, $fieldModel);
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phan

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

                          $id = (new \App\Db\Query())->from($tableName)->where(['invtype' => $fieldModel->getType()])->max('id') + 1;
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by phan

              Reference to undeclared property \Vtiger_Basic_InventoryField->shared
              Open

                              foreach ($fieldModel->shared as $column => $columnShared) {
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phan

              Call to method notNull from undeclared class \yii\db\ColumnSchemaBuilder (Did you mean class \App\Db\Drivers\Mysql\ColumnSchemaBuilder or class \App\Db\Drivers\Pgsql\ColumnSchemaBuilder)
              Open

                                  'columnname' => $importer->stringType(30)->notNull(),
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by phan

              Return type of getAllColumns() is undeclared type \astring[] (Did you mean string)
              Open

                  public function getAllColumns()
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phan

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

                          $dataReader = (new \App\Db\Query())->from($this->getTableName(self::TABLE_POSTFIX_MAP))->createCommand()->query();
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by phan

              Call to method notNull from undeclared class \yii\db\ColumnSchemaBuilder (Did you mean class \App\Db\Drivers\Mysql\ColumnSchemaBuilder or class \App\Db\Drivers\Pgsql\ColumnSchemaBuilder)
              Open

                                  'label' => $importer->stringType(50)->notNull(),
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by phan

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

                          $row = (new \App\Db\Query())->from($this->getTableName())->where(['id' => $fieldId])->one();
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by phan

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

                      $query = (new \App\Db\Query())->from($inventory->getTableName(self::TABLE_POSTFIX_DATA))->indexBy('id')->where(['crmid' => $recordId]);
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by phan

              Reference to undeclared property \Vtiger_Basic_InventoryField->shared
              Open

                          if (isset($fieldModel->shared)) {
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phan

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

                          $dataReader = (new \App\Db\Query())->from('a_#__discounts_config')->createCommand(\App\Db::getInstance('admin'))->query();
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by phan

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

                      if (\App\Cache::staticHas(__METHOD__, $fieldId)) {
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phan

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

                          \App\Log::error($ex->__toString());
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by phan

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

                          \App\Log::error($ex->__toString());
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by phan

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

                      $taxes = (new App\Db\Query())->from('a_#__taxes_global')->where(['status' => 0])
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by phan

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

                              $result = $db->createCommand()->update($tableName, $data, ['id' => $fieldModel->get('id')])->execute();
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by phan

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

                      $discounts = (new App\Db\Query())->from('a_#__discounts_global')->where(['status' => 0])
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by phan

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

                          $dataReader = (new \App\Db\Query())->from($this->getTableName())->indexBy('columnname')
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by phan

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

                  public function saveField(Vtiger_Basic_InventoryField $fieldModel): bool
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phan

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

                      $transaction = $db->beginTransaction();
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by phan

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

                  public function saveSequence(array $sequenceList): int
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phan

              Saw an @param annotation for moduleName, but it was not found in the param list of function getAccountDiscount(mixed $relatedRecord) : array
              Open

                   * @param string $moduleName    Module name
              Severity: Info
              Found in modules/Vtiger/models/Inventory.php by phan

              Call to method unsigned from undeclared class \yii\db\ColumnSchemaBuilder (Did you mean class \App\Db\Drivers\Mysql\ColumnSchemaBuilder or class \App\Db\Drivers\Pgsql\ColumnSchemaBuilder)
              Open

                                  'sequence' => $importer->integer(10)->unsigned()->notNull(),
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by phan

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

                          $case .= " WHEN {$db->quoteValue($id)} THEN {$db->quoteValue($sequence)}";
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by phan

              Saw an @param annotation for record, but it was not found in the param list of function getAccountDiscount(mixed $relatedRecord) : array
              Open

                   * @param int    $record        Record ID
              Severity: Info
              Found in modules/Vtiger/models/Inventory.php by phan

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

                      $dbCommand = $db->createCommand();
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by phan

              Call to method notNull from undeclared class \yii\db\ColumnSchemaBuilder (Did you mean class \App\Db\Drivers\Mysql\ColumnSchemaBuilder or class \App\Db\Drivers\Pgsql\ColumnSchemaBuilder)
              Open

                                  'invtype' => $importer->stringType(30)->notNull(),
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by phan

              Call to method unsigned from undeclared class \yii\db\ColumnSchemaBuilder (Did you mean class \App\Db\Drivers\Mysql\ColumnSchemaBuilder or class \App\Db\Drivers\Pgsql\ColumnSchemaBuilder)
              Open

                                  'presence' => $importer->smallInteger(1)->unsigned()->notNull()->defaultValue(0),
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by phan

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

                              $result = $db->createCommand()->insert($tableName, $data)->execute();
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by phan

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

                      return $db->createCommand()->update($this->getTableName(), ['sequence' => new \yii\db\Expression($case)], ['id' => $sequenceList])->execute();
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by phan

              Call to undeclared method \Vtiger_Base_UIType::getValueForCurrency
              Open

                              $data['price'] = $fieldModel->getUITypeModel()->getValueForCurrency($recordModel->get($fieldModel->getName()), $currencyId);
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by phan

              Call to method unsigned from undeclared class \yii\db\ColumnSchemaBuilder (Did you mean class \App\Db\Drivers\Mysql\ColumnSchemaBuilder or class \App\Db\Drivers\Pgsql\ColumnSchemaBuilder)
              Open

                                  'block' => $importer->smallInteger(1)->unsigned()->notNull(),
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by phan

              Call to method notNull from undeclared class \yii\db\ColumnSchemaBuilder (Did you mean class \App\Db\Drivers\Mysql\ColumnSchemaBuilder or class \App\Db\Drivers\Pgsql\ColumnSchemaBuilder)
              Open

                                  'module' => $importer->stringType(50)->notNull(),
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by phan

              Call to undeclared method \Vtiger_Base_UIType::getValueForCurrency
              Open

                              $data['purchase'] = $fieldModel->getUITypeModel()->getValueForCurrency($recordModel->get($fieldModel->getName()), $currencyId);
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by phan

              Call to method unsigned from undeclared class \yii\db\ColumnSchemaBuilder (Did you mean class \App\Db\Drivers\Mysql\ColumnSchemaBuilder or class \App\Db\Drivers\Pgsql\ColumnSchemaBuilder)
              Open

                                  'colspan' => $importer->smallInteger(1)->unsigned()->notNull()->defaultValue(1),
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by phan

              Call to method notNull from undeclared class \yii\db\ColumnSchemaBuilder (Did you mean class \App\Db\Drivers\Mysql\ColumnSchemaBuilder or class \App\Db\Drivers\Pgsql\ColumnSchemaBuilder)
              Open

                                  'tofield' => $importer->stringType(50)->notNull(),
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by phan

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

                      $transaction = $db->beginTransaction();
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by phan

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

                  public function deleteField(string $fieldName): bool
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phan

              Reference to undeclared property \CRMEntity->table_index
              Open

                                  ["{$dataTableName}_crmid_fk", $dataTableName, 'crmid', $focus->table_name, $focus->table_index, 'CASCADE', null]
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phan

              Reference to undeclared property \CRMEntity->table_name
              Open

                                  ["{$dataTableName}_crmid_fk", $dataTableName, 'crmid', $focus->table_name, $focus->table_index, 'CASCADE', null]
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phan

              Call to method unsigned from undeclared class \yii\db\ColumnSchemaBuilder (Did you mean class \App\Db\Drivers\Mysql\ColumnSchemaBuilder or class \App\Db\Drivers\Pgsql\ColumnSchemaBuilder)
              Open

                                  'displaytype' => $importer->smallInteger(1)->unsigned()->notNull()->defaultValue(1),
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by phan

              Call to method __construct from undeclared class \yii\db\Expression
              Open

                      return $db->createCommand()->update($this->getTableName(), ['sequence' => new \yii\db\Expression($case)], ['id' => $sequenceList])->execute();
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by phan

              Call to method notNull from undeclared class \yii\db\ColumnSchemaBuilder (Did you mean class \App\Db\Drivers\Mysql\ColumnSchemaBuilder or class \App\Db\Drivers\Pgsql\ColumnSchemaBuilder)
              Open

                                  'field' => $importer->stringType(50)->notNull(),
              Severity: Critical
              Found in modules/Vtiger/models/Inventory.php by phan

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

                  public function getGlobalDiscounts()
                  {
                      if (\App\Cache::has('Inventory', 'Discounts')) {
                          return \App\Cache::get('Inventory', 'Discounts');
                      }
              Severity: Major
              Found in modules/Vtiger/models/Inventory.php and 2 other locations - About 1 hr to fix
              modules/Vtiger/models/Inventory.php on lines 653..662
              modules/Vtiger/uitypes/InventoryLimit.php on lines 76..86

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

              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 3 locations. Consider refactoring.
              Open

                  public static function getGlobalTaxes()
                  {
                      if (\App\Cache::has('Inventory', 'Taxes')) {
                          return \App\Cache::get('Inventory', 'Taxes');
                      }
              Severity: Major
              Found in modules/Vtiger/models/Inventory.php and 2 other locations - About 1 hr to fix
              modules/Vtiger/models/Inventory.php on lines 614..623
              modules/Vtiger/uitypes/InventoryLimit.php on lines 76..86

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

              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 Vtiger_Inventory_Model

              The class Vtiger_Inventory_Model is not named in CamelCase.
              Open

              class Vtiger_Inventory_Model
              {
                  /**
                   * Field configuration table postfix.
                   */
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              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();
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              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();
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              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();
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              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();
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              ShortVariable

              Since: 0.2

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

              Example

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

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

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

                          $id = (new \App\Db\Query())->from($tableName)->where(['invtype' => $fieldModel->getType()])->max('id') + 1;
              Severity: Minor
              Found in modules/Vtiger/models/Inventory.php by phpmd

              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

                   */

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

                   */

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

                   * Field configuration table postfix.

              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

                  protected $tableName;

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

                   * @var \Vtiger_Basic_InventoryField[] Inventory fields

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

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

                   */

              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

                   * Gets inventory 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

                   * Field mapping table postfix.

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

                  protected $moduleName;

              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

                   * @return self

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

                  private const TABLE_POSTFIX_BASE = '_invfield';

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

                  private const TABLE_POSTFIX_DATA = '_inventory';

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

                   */

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

                   * @param string $moduleName

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

                   * @throws \App\Exceptions\AppException

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

                   *

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

                   * Data table postfix.

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

                  private const TABLE_POSTFIX_MAP = '_invmap';

              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

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

                   *

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

                          $row = (new \App\Db\Query())->from($this->getTableName())->where(['id' => $fieldId])->one();

              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 static function getInstance(string $moduleName): self

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

                  protected function setModuleName(string $name)

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

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

                          $this->fields = [];

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

                              $fieldModel = Vtiger_Basic_InventoryField::getInstance($this->moduleName, $row['invtype']);

              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 getFieldById(int $fieldId): ?Vtiger_Basic_InventoryField

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

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

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

                   * @param string $name

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

                   */

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

                  public function getFields(): array

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

                      foreach ($this->getFields() 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

                   * @param string $type

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

                   * @throws \App\Exceptions\AppException

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

                  {

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

                      return $this->moduleName;

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

                  }

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

                   */

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

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

                          $instance = new $modelClassName();

              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 getTableName(string $type = self::TABLE_POSTFIX_BASE): 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

                   * Gets inventory fields.

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

                   * @throws \App\Exceptions\AppException

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

                   *

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

                   * @return \Vtiger_Basic_InventoryField[]

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

                      $fieldList = [];

              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 \Vtiger_Basic_InventoryField[]

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

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

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

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

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

                   *

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

                   *

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

                          $fieldModel = \App\Cache::staticGet(__METHOD__, $fieldId);

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

                   * Function that returns all the fields by blocks.

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

                   * Gets inventory fields by 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

                  {

              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(__METHOD__, $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

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

                          $this->tableName = CRMEntity::getInstance($this->moduleName)->table_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

                          if ($row) {

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

                      $fieldList = [];

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

                   * @throws \App\Exceptions\AppException

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

                   * Gets the field for the view.

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

                          $modelClassName = Vtiger_Loader::getComponentClassName('Model', 'Inventory', $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

                   * @return string

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

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

                   * Gets table name.

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

                   * Gets data table 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

                      return $this->getFields()[$fieldName] ?? 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

                          $fieldList[$fieldModel->get('block')][$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 $this->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

                  /**

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

                              $this->setFieldData($fieldModel, $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

                      return $fieldList;

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

                          $instance->setModuleName($moduleName);

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

                   * Function returns module name.

              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

                          $dataReader = (new \App\Db\Query())->from($this->getTableName())->indexBy('columnname')

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

                          }

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

                   * Gets inventory field model by ID.

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

                      return $fieldModel;

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

                  public function getFieldsByBlocks(): array

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

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

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

                   * @param string $view

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

                   * @throws \App\Exceptions\AppException

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

                   * Gets inventory field model.

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

                   * @return \Vtiger_Basic_InventoryField|null

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

                   * @return \Vtiger_Basic_InventoryField|null

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

                          \App\Cache::staticSave(__METHOD__, $fieldId, $fieldModel);

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

                   * @throws \App\Exceptions\AppException

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

                      return $instance;

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

                  {

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

                   * @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 getFieldsByType(string $type): 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

                   * Sets module 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

                   * @param int $fieldId

              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 = \App\Cache::staticGet(__METHOD__, $moduleName);

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

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

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

                      return $this->getTableName(self::TABLE_POSTFIX_DATA);

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

                   */

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

                   *

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

                  public function getField(string $fieldName): ?Vtiger_Basic_InventoryField

              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

                          if ($type === $fieldModel->getType()) {

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

                   * @return string

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

                   */

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

                  public function getDataTableName(): string

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

                              $this->setFieldData($fieldModel, $row);

              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

                  {

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

                      if (\App\Cache::staticHas(__METHOD__, $fieldId)) {

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

                              $fieldModel = $this->getFieldCleanInstance($row['invtype']);

              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

                              ->orderBy(['block' => SORT_ASC, 'sequence' => SORT_ASC])->createCommand()->query();

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

                              $this->fields[$row['columnname']] = $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

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

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

                   * Sets inventory field data.

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

                   * @param string                    $moduleName

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

                  {

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

                          if (0 !== $pagingModel->get('limit')) {

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

                          if ($fieldModel->isEmpty('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

                          ->set('columnName', $row['columnname'])

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

                  }

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

                          } else {

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

                          return $rows;

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

                                  vtlib\Utils::addColumn($table, $column, $criteria);

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

                      $fieldList = [];

              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->getFields() as $name => $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

                  public function getFieldCleanInstance(string $type): Vtiger_Basic_InventoryField

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

                          $rows = $query->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

                      return $query->all();

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

                          $id = (new \App\Db\Query())->from($tableName)->where(['invtype' => $fieldModel->getType()])->max('id') + 1;

              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

                          case 'DetailPreview':

              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 setFieldData(Vtiger_Basic_InventoryField $fieldModel, array $row)

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

                      $fieldModel->set('id', (int) $row['id'])

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

                          ->set('label', $row['label'])

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

                   */

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

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

                      }

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

              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

                          ->set('sequence', (int) $row['sequence'])

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

                      if ($fieldModel->isEmpty('id') && !$fieldModel->isOnlyOne()) {

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

                              foreach ($fieldModel->getCustomColumn() as $column => $criteria) {

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

                  public function getFieldsForView(string $view): array

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

                                  if ($fieldModel->isVisibleInDetail()) {

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

                  public function getSummaryFields(): 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 \Vtiger_Basic_InventoryField $fieldModel

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

                   * @throws \App\Exceptions\AppException

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

                   * @param int                       $recordId

              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

                  }

              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

                          ->set('presence', (int) $row['presence'])

              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_Basic_InventoryField::getInstance($this->getModuleName(), $type);

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

                      if ($pagingModel) {

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

                      if (!$fieldModel->has('sequence')) {

              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

                   *

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

                          ->set('block', (int) $row['block'])

              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

                   * Gets clean inventory field instance.

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

                   * @throws \App\Exceptions\AppException

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

                  {

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

                  }

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

                   * @return array

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

                  public static function getInventoryDataById(int $recordId, string $moduleName, ?Vtiger_Paging_Model $pagingModel = null): 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 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

                          $fieldModel->set('sequence', $db->getUniqueID($tableName, 'sequence', false));

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

                   */

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

                   * @param \Vtiger_Paging_Model|null $pagingModel

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

                   *

              Line exceeds 120 characters; contains 143 characters
              Open

                      $query = (new \App\Db\Query())->from($inventory->getTableName(self::TABLE_POSTFIX_DATA))->indexBy('id')->where(['crmid' => $recordId]);

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

                              $query->limit($pageLimit + 1)->offset($pagingModel->getStartIndex());

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

                          $count = \count($rows);

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

                              $pagingModel->set('nextPageExists', 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

                              $fieldModel->set('id', $db->getLastInsertID("{$tableName}_id_seq"));

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

                          ->set('defaultValue', $row['defaultvalue'])

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

                          ->set('displayType', (int) $row['displaytype'])

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

                              array_pop($rows);

              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 \Vtiger_Basic_InventoryField[]

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

                      return $summaryFields;

              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 data of inventory for 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

                          }

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

                                      $fieldList[$fieldModel->get('block')][$fieldName] = $fieldModel;

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

                      return $fieldList;

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

                   * Getting summary fields name.

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

                              $summaryFields[$name] = $name;

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

                          ->set('colSpan', (int) $row['colspan']);

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

                   *

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

                      $inventory = self::getInstance($moduleName);

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

                          $pageLimit = $pagingModel->getPageLimit();

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

                   * @throws \yii\db\Exception

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

                   * @throws \App\Exceptions\AppException

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

                          ->set('params', $row['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

                   * @param string $fieldName

              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

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

                   * @return \Vtiger_Basic_InventoryField

              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

                      $tableName = $this->getTableName();

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

                          case 'Detail':

              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

                   * @throws \App\Exceptions\AppException

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

                      if ($inventory->isField('seq')) {

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

                   * Save inventory 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

                          $fieldModel->set('columnName', $fieldModel->getColumnName() . $id);

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

                          $data = array_change_key_case($fieldModel->getData(), CASE_LOWER);

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

                      switch ($view) {

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

                      $summaryFields = [];

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

                   *

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

                          $query->orderBy(['seq' => SORT_ASC]);

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

                          if ($count > $pageLimit) {

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

                          $pagingModel->calculatePageRange($count);

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

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

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

                              $table = $this->getTableName(self::TABLE_POSTFIX_DATA);

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

                              vtlib\Utils::addColumn($table, $fieldModel->getColumnName(), $fieldModel->getDBType());

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

                              $result = $db->createCommand()->insert($tableName, $data)->execute();

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

                              foreach ($this->getFields() 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

                   * Checks if inventory field exists.

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

                      return isset($this->getFields()[$fieldName]);

              Line exceeds 120 characters; contains 131 characters
              Open

                  public static function getInventoryDataById(int $recordId, string $moduleName, ?Vtiger_Paging_Model $pagingModel = null): array

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

                      $query = (new \App\Db\Query())->from($inventory->getTableName(self::TABLE_POSTFIX_DATA))->indexBy('id')->where(['crmid' => $recordId]);

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

                              $pagingModel->set('nextPageExists', false);

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

                   *

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

                   * @param \Vtiger_Basic_InventoryField $fieldModel

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

                  public function saveField(Vtiger_Basic_InventoryField $fieldModel): bool

              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

                          $transaction->commit();

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

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

                          $columns[] = $field->getColumnName();

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

              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

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

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

                   * Save sequence field.

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

                   * @throws \App\Exceptions\AppException

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

                          if ('Vtiger' !== $moduleName) {

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

                  /**

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

                  /**

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

                      }

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

                      }

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

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

                              if (!is_dir($fieldPath)) {

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

                      foreach ($this->getFields() as $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

                          $dataReader = (new \App\Db\Query())->from($this->getTableName(self::TABLE_POSTFIX_MAP))->createCommand()->query();

              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 = $db->beginTransaction();

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

                  public function saveSequence(array $sequenceList): int

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

                              foreach (new DirectoryIterator($fieldPath) as $object) {

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

                   * @throws \App\Exceptions\AppException

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

                   * @return astring[]

              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

                          $transaction->commit();

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

                          $case .= " WHEN {$db->quoteValue($id)} THEN {$db->quoteValue($sequence)}";

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

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

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

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

              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::has(__METHOD__, $moduleName)) {

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

                   * Gets all columns.

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

                  {

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

                      $columns = [];

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

                          App\Cache::save(__METHOD__, $moduleName, $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 (bool) $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

                      try {

              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

                      $case = 'CASE id';

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

                   * @return \Vtiger_Basic_InventoryField[] Fields instance

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

                          $inventoryTypes = \App\Cache::get(__METHOD__, $moduleName);

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

                          $fieldPaths = ["modules/$moduleName/inventoryfields/"];

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

                          foreach ($fieldPaths as $fieldPath) {

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

                      return $columns;

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

                   *

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

                   *

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

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

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

                   * @throws \yii\db\Exception

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

                   * Function return autocomplete fields.

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

                   * Function to get custom values to complete in inventory.

              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->isField($columnShared) && false !== ($key = array_search($column, $columnsArray))) {

              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

                      foreach ($sequenceList as $sequence => $id) {

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

                                  if ('php' === $object->getExtension() && 'Basic' !== ($type = $object->getBasename('.php')) && !isset($inventoryTypes[$type])) {

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

                                      $inventoryTypes[$type] = Vtiger_Basic_InventoryField::getInstance($moduleName, $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

                  }

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

                      $moduleName = $this->getModuleName();

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

                      if (\App\Cache::has(__METHOD__, $moduleName)) {

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

                   * Delete inventory field.

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

                          if ('seq' !== $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

                  /**

              Line exceeds 120 characters; contains 150 characters
              Open

                      return $db->createCommand()->update($this->getTableName(), ['sequence' => new \yii\db\Expression($case)], ['id' => $sequenceList])->execute();

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

                          $transaction->rollBack();

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

                   * Retrieve list of all fields.

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

                  public function getFieldsTypes(): array

              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

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

                          $columnsArray = array_keys($fieldModel->getCustomColumn());

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

                      }

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

                   *

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

                          if (isset($fieldModel->shared)) {

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

                   * @param int[] $sequenceList

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

              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

                                  continue;

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

                   * @throws \yii\db\Exception

              Line exceeds 120 characters; contains 148 characters
              Open

                                  if ('php' === $object->getExtension() && 'Basic' !== ($type = $object->getBasename('.php')) && !isset($inventoryTypes[$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

                                  }

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

                      $moduleName = $this->getModuleName();

              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

                              $columns[] = $name;

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

                          \App\Cache::save(__METHOD__, $moduleName, $inventoryTypes);

              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

                              $result = $db->createCommand()->update($tableName, $data, ['id' => $fieldModel->get('id')])->execute();

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

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

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

                      $dbCommand = $db->createCommand();

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

                                  $dbCommand->dropColumn($this->getTableName(self::TABLE_POSTFIX_DATA), $column)->execute();

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

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

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

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

                   */

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

                              $fieldPaths[] = 'modules/Vtiger/inventoryfields/';

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

                  public function getAllColumns()

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

                          $fields = \App\Cache::get(__METHOD__, $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

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

                          $columnsArray[] = $fieldName;

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

                              foreach ($columnsArray as $column) {

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

                      return $db->createCommand()->update($this->getTableName(), ['sequence' => new \yii\db\Expression($case)], ['id' => $sequenceList])->execute();

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

                          }

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

                          foreach ($field->getCustomColumn() as $name => $field) {

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

                              $fields[$row['module']][$row['tofield']] = $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

                              foreach ($fieldModel->shared as $column => $columnShared) {

              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

                          $inventoryTypes = [];

              Line exceeds 120 characters; contains 126 characters
              Open

                          $dataReader = (new \App\Db\Query())->from($this->getTableName(self::TABLE_POSTFIX_MAP))->createCommand()->query();

              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

                          $dbCommand->delete($this->getTableName(), ['columnname' => $fieldName])->execute();

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

                      $case .= ' END ';

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

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

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

                  /**

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

                   * @param Vtiger_Record_Model $recordModel

              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($mapping[$sourceFieldName]) && method_exists($this, $mapping[$sourceFieldName])) {

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

                   * @param \Vtiger_Record_Model $recordModel

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

                  {

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

                          $html .= $field->getDisplayValue($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

                   * @return array

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

                  public function getPurifyTemplate(): array

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

                          $template += $fieldModel->getPurifyType();

              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::has('Inventory', 'TaxConfiguration')) {

              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 float

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

                      return $recordModel->isEmpty('sum_total') ? 0 : $recordModel->get('sum_total');

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

                      $html = '<ul>';

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

                  /**

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

                      $template = [];

              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(App\Db::getInstance('admin'))->queryAllByGroup(1);

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

                      \App\Cache::save('Inventory', 'Discounts', $discounts, \App\Cache::LONG);

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

                          $config[$row['param']] = $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

                      if ($inventoryMap) {

              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

                          $dataReader = (new \App\Db\Query())->from('a_#__discounts_config')->createCommand(\App\Db::getInstance('admin'))->query();

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

                      \App\Cache::save('Inventory', 'Taxes', $taxes, \App\Cache::LONG);

              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

                   * @throws \App\Exceptions\AppException

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

                   * @param string $key

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

                  {

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

                          $config = [];

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

                              $value = $row['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 \App\Cache::get('Inventory', 'TaxConfiguration');

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

                      $dataReader = (new App\Db\Query())->from('a_#__taxes_config')->createCommand(App\Db::getInstance('admin'))->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

                      return $values;

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

                   * Gets data from 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

                      }

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

                              $config[$row['param']] = $value;

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

                      return $config;

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

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

                   * Get default global tax .

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

                          return \App\Cache::get('Inventory', 'DefaultTax');

              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 {

              Line exceeds 120 characters; contains 134 characters
              Open

                          $dataReader = (new \App\Db\Query())->from('a_#__discounts_config')->createCommand(\App\Db::getInstance('admin'))->query();

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

                      if (\App\Cache::has('Inventory', 'Discounts')) {

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

                          if (\in_array($row['param'], ['taxs'])) {

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

                      return $taxes;

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

                  public static function getDefaultGlobalTax()

              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 getInventoryPrice(Vtiger_Record_Model $recordModel)

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

                  public function getInventoryListName(Vtiger_Record_Model $recodModel)

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

                          $html .= '<li>';

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

                   * @return mixed config data

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

                          $config = \App\Cache::get('Inventory', 'DiscountConfiguration');

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

                   * Get global discounts list.

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

                  }

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

                              }

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

                   *

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

                   *

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

                      foreach ($recodModel->getInventoryData() as $data) {

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

                   * Gets template to purify.

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

                  /**

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

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

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

                  public function getGlobalDiscounts()

              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::save('Inventory', 'TaxConfiguration', $config, \App\Cache::LONG);

              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

                          \App\Cache::save('Inventory', 'DiscountConfiguration', $config, \App\Cache::LONG);

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

                          foreach ($inventoryMap as $fieldToComplete => $mapping) {

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

                                  $methodName = $mapping[$sourceFieldName];

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

                                  $values[$fieldToComplete] = $this->{$methodName}($recordModel);

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

                      return $template;

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

                   * Get discounts configuration.

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

                      if (\App\Cache::has('Inventory', 'DiscountConfiguration')) {

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

                   * @return array discounts list

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

                   *

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

                      $config = [];

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

                      if (\App\Cache::has('Inventory', 'Taxes')) {

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

                      $inventoryMap = App\Config::module($this->getModuleName(), 'INVENTORY_ON_SELECT_AUTO_COMPLETE');

              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 \App\Cache::get('Inventory', 'Discounts');

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

                      $discounts = (new App\Db\Query())->from('a_#__discounts_global')->where(['status' => 0])

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

                      return $discounts;

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

                   * Get global tax list.

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

                          return \App\Cache::get('Inventory', 'Taxes');

              Spaces must be used to indent lines; tabs are not allowed
              Open

                  public function getCustomAutoComplete(string $sourceFieldName, Vtiger_Record_Model $recordModel)

              Spaces must be used to indent lines; tabs are not allowed
              Open

                          }

              Spaces must be used to indent lines; tabs are not allowed
              Open

                      }

              Spaces must be used to indent lines; tabs are not allowed
              Open

                   *

              Spaces must be used to indent lines; tabs are not allowed
              Open

                   */

              Spaces must be used to indent lines; tabs are not allowed
              Open

                      }

              Spaces must be used to indent lines; tabs are not allowed
              Open

                  public static function getTaxesConfig()

              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

                              $value = explode(',', $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

                   * @param \Vtiger_Record_Model $recodModel

              Spaces must be used to indent lines; tabs are not allowed
              Open

                   * @return string

              Spaces must be used to indent lines; tabs are not allowed
              Open

                      return $html . '</ul>';

              Spaces must be used to indent lines; tabs are not allowed
              Open

                      foreach ($this->getFields() as $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

                      $taxes = (new App\Db\Query())->from('a_#__taxes_global')->where(['status' => 0])

              Spaces must be used to indent lines; tabs are not allowed
              Open

                  /**

              Spaces must be used to indent lines; tabs are not allowed
              Open

                      if (\App\Cache::has('Inventory', 'DefaultTax')) {

              Spaces must be used to indent lines; tabs are not allowed
              Open

                   * @throws \App\Exceptions\AppException

              Spaces must be used to indent lines; tabs are not allowed
              Open

                  public static function getDiscountsConfig(string $key = '')

              Spaces must be used to indent lines; tabs are not allowed
              Open

                              if (\in_array($row['param'], ['discounts'])) {

              Spaces must be used to indent lines; tabs are not allowed
              Open

                                  $value = explode(',', $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 static function getGlobalTaxes()

              Spaces must be used to indent lines; tabs are not allowed
              Open

                   * Function to get list elements in iventory as html code.

              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 $key ? $config[$key] : $config;

              Spaces must be used to indent lines; tabs are not allowed
              Open

                   */

              Line exceeds 120 characters; contains 124 characters
              Open

                      $dataReader = (new App\Db\Query())->from('a_#__taxes_config')->createCommand(App\Db::getInstance('admin'))->query();

              Spaces must be used to indent lines; tabs are not allowed
              Open

                          $value = $row['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 tax list

              Spaces must be used to indent lines; tabs are not allowed
              Open

                      $values = [];

              Spaces must be used to indent lines; tabs are not allowed
              Open

                      $field = $this->getField('name');

              Spaces must be used to indent lines; tabs are not allowed
              Open

                          $html .= '</li>';

              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 tax configuration.

              Spaces must be used to indent lines; tabs are not allowed
              Open

                          ->createCommand(App\Db::getInstance('admin'))->queryAllByGroup(1);

              Spaces must be used to indent lines; tabs are not allowed
              Open

                  /**

              Spaces must be used to indent lines; tabs are not allowed
              Open

                  public function createInventoryTables()

              Spaces must be used to indent lines; tabs are not allowed
              Open

                      $mapTableName = $this->getTableName(self::TABLE_POSTFIX_MAP);

              Line exceeds 120 characters; contains 132 characters
              Open

                                  ["{$dataTableName}_crmid_fk", $dataTableName, 'crmid', $focus->table_name, $focus->table_index, 'CASCADE', 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

                          $mapTableName => [

              Spaces must be used to indent lines; tabs are not allowed
              Open

                                  'field' => $importer->stringType(50)->notNull(),

              Spaces must be used to indent lines; tabs are not allowed
              Open

                                  'tofield' => $importer->stringType(50)->notNull(),

              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   $recordId

              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 getAccountTax($relatedRecord)

              Spaces must be used to indent lines; tabs are not allowed
              Open

                                  'seq' => $importer->integer(10),

              Spaces must be used to indent lines; tabs are not allowed
              Open

                                  'module' => $importer->stringType(50)->notNull(),

              Spaces must be used to indent lines; tabs are not allowed
              Open

                              ],

              Spaces must be used to indent lines; tabs are not allowed
              Open

                              'engine' => 'InnoDB',

              Spaces must be used to indent lines; tabs are not allowed
              Open

                              $base->addTables($importer);

              Spaces must be used to indent lines; tabs are not allowed
              Open

                          $currencyId = $params['currency'] ?? \App\Fields\Currency::getDefault()['id'];

              Spaces must be used to indent lines; tabs are not allowed
              Open

                      \App\Cache::save('Inventory', 'DefaultTax', $defaultTax, \App\Cache::LONG);

              Spaces must be used to indent lines; tabs are not allowed
              Open

                      return ['discount' => $discount, 'name' => $recordName];

              Spaces must be used to indent lines; tabs are not allowed
              Open

                  }

              Spaces must be used to indent lines; tabs are not allowed
              Open

                                  'crmid' => $importer->integer(10),

              Spaces must be used to indent lines; tabs are not allowed
              Open

                              ]

              Spaces must be used to indent lines; tabs are not allowed
              Open

                              'primaryKeys' => [

              Spaces must be used to indent lines; tabs are not allowed
              Open

                          }

              Spaces must be used to indent lines; tabs are not allowed
              Open

                          'name' => $recordId,

              Line exceeds 120 characters; contains 140 characters
              Open

                              $data['price'] = $fieldModel->getUITypeModel()->getValueForCurrency($recordModel->get($fieldModel->getName()), $currencyId);

              Line exceeds 120 characters; contains 143 characters
              Open

                              $data['purchase'] = $fieldModel->getUITypeModel()->getValueForCurrency($recordModel->get($fieldModel->getName()), $currencyId);

              Spaces must be used to indent lines; tabs are not allowed
              Open

                      $discount = 0;

              Spaces must be used to indent lines; tabs are not allowed
              Open

                   * Get tax from the account.

              Spaces must be used to indent lines; tabs are not allowed
              Open

                      }

              Spaces must be used to indent lines; tabs are not allowed
              Open

                                  'defaultvalue' => $importer->stringType(),

              Spaces must be used to indent lines; tabs are not allowed
              Open

                                  'displaytype' => $importer->smallInteger(1)->unsigned()->notNull()->defaultValue(1),

              Spaces must be used to indent lines; tabs are not allowed
              Open

                              'charset' => 'utf8',

              Spaces must be used to indent lines; tabs are not allowed
              Open

                      foreach ($tables as $tableName => $data) {

              Spaces must be used to indent lines; tabs are not allowed
              Open

                              $importer->tables = [$tableName => $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

                      $recordModuleName = $recordModel->getModuleName();

              Spaces must be used to indent lines; tabs are not allowed
              Open

                      if (!$recordModel->isEmpty('description')) {

              Spaces must be used to indent lines; tabs are not allowed
              Open

                          ->one();

              Spaces must be used to indent lines; tabs are not allowed
              Open

                   * Get discount from the account.

              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

                   * Create inventory tables.

              Spaces must be used to indent lines; tabs are not allowed
              Open

                      $importer = new \App\Db\Importers\Base();

              Spaces must be used to indent lines; tabs are not allowed
              Open

                              'engine' => 'InnoDB',

              Spaces must be used to indent lines; tabs are not allowed
              Open

                                  ["{$dataTableName}_crmid_fk", $dataTableName, 'crmid', $focus->table_name, $focus->table_index, 'CASCADE', null]

              Spaces must be used to indent lines; tabs are not allowed
              Open

                                  $importer->foreignKey = $data['foreignKey'];

              Spaces must be used to indent lines; tabs are not allowed
              Open

                              if ($fieldModel && ($fieldValue = $recordModel->get($field['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 int    $record        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

                  {

              Spaces must be used to indent lines; tabs are not allowed
              Open

                          $dataTableName => [

              Spaces must be used to indent lines; tabs are not allowed
              Open

                              if (isset($data['foreignKey'])) {

              Spaces must be used to indent lines; tabs are not allowed
              Open

                      $data = [

              Spaces must be used to indent lines; tabs are not allowed
              Open

                      ];

              Spaces must be used to indent lines; tabs are not allowed
              Open

                      if (\in_array($recordModuleName, ['Products', 'Services'])) {

              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[$field['tofield']] = $fieldValue;

              Spaces must be used to indent lines; tabs are not allowed
              Open

                          $accountRecordModel = Vtiger_Record_Model::getInstanceById($relatedRecord);

              Spaces must be used to indent lines; tabs are not allowed
              Open

                      $db = \App\Db::getInstance();

              Spaces must be used to indent lines; tabs are not allowed
              Open

                      $focus = CRMEntity::getInstance($this->getModuleName());

              Spaces must be used to indent lines; tabs are not allowed
              Open

                      $base = new \App\Db\Importer();

              Spaces must be used to indent lines; tabs are not allowed
              Open

                      $base->dieOnError = App\Config::debug('SQL_DIE_ON_ERROR');

              Spaces must be used to indent lines; tabs are not allowed
              Open

                              $data['price'] = $fieldModel->getUITypeModel()->getValueForCurrency($recordModel->get($fieldModel->getName()), $currencyId);

              Spaces must be used to indent lines; tabs are not allowed
              Open

                      if ($autoCompleteField = ($this->getAutoCompleteFields()[$recordModuleName] ?? [])) {

              Spaces must be used to indent lines; tabs are not allowed
              Open

                              $fieldModel = $recordModel->getField($field['field']);

              Spaces must be used to indent lines; tabs are not allowed
              Open

                   * @param mixed  $relatedRecord

              Spaces must be used to indent lines; tabs are not allowed
              Open

                          $accountTaxes = Vtiger_Taxes_UIType::getValues($accountRecordModel->get($taxField->getName()));

              Spaces must be used to indent lines; tabs are not allowed
              Open

                              'columns' => [

              Spaces must be used to indent lines; tabs are not allowed
              Open

                              'engine' => 'InnoDB',

              Spaces must be used to indent lines; tabs are not allowed
              Open

                                  ["{$mapTableName}_pk", ['module', 'field', 'tofield']],

              Spaces must be used to indent lines; tabs are not allowed
              Open

                                  $base->addForeignKey($importer);

              Spaces must be used to indent lines; tabs are not allowed
              Open

                      return $defaultTax;

              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

                      $discountField = 'discount';

              Spaces must be used to indent lines; tabs are not allowed
              Open

                      $accountTaxes = [];

              Line exceeds 120 characters; contains 221 characters
              Open

                      if (!empty($relatedRecord) && \App\Record::isExists($relatedRecord, $sourceModule) && ($taxField = current(Vtiger_Module_Model::getInstance($sourceModule)->getFieldsByUiType(303))) && $taxField->isActiveField()) {

              Spaces must be used to indent lines; tabs are not allowed
              Open

                      $dataTableName = $this->getTableName(self::TABLE_POSTFIX_DATA);

              Spaces must be used to indent lines; tabs are not allowed
              Open

                              ],

              Spaces must be used to indent lines; tabs are not allowed
              Open

                   *

              Spaces must be used to indent lines; tabs are not allowed
              Open

                   *

              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

                              ],

              Spaces must be used to indent lines; tabs are not allowed
              Open

                              'foreignKey' => [

              Spaces must be used to indent lines; tabs are not allowed
              Open

                                  'block' => $importer->smallInteger(1)->unsigned()->notNull(),

              Spaces must be used to indent lines; tabs are not allowed
              Open

                                  'colspan' => $importer->smallInteger(1)->unsigned()->notNull()->defaultValue(1),

              Spaces must be used to indent lines; tabs are not allowed
              Open

                   * Load row data by record Id.

              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

                      $recordModel = Vtiger_Record_Model::getInstanceById($recordId);

              Spaces must be used to indent lines; tabs are not allowed
              Open

                          if (($fieldModel = $recordModel->getField('unit_price')) && $fieldModel->isActiveField()) {

              Spaces must be used to indent lines; tabs are not allowed
              Open

                          }

              Line exceeds 120 characters; contains 121 characters
              Open

                      $defaultTax = (new App\Db\Query())->from('a_#__taxes_global')->where(['status' => 0])->andWhere(['default' => 1])

              Spaces must be used to indent lines; tabs are not allowed
              Open

                   * @param string $moduleName    Module name

              Spaces must be used to indent lines; tabs are not allowed
              Open

                      if (!empty($relatedRecord)) {

              Spaces must be used to indent lines; tabs are not allowed
              Open

                          $discount = $accountRecordModel->get($discountField);

              Spaces must be used to indent lines; tabs are not allowed
              Open

                      $sourceModule = 'Accounts';

              Spaces must be used to indent lines; tabs are not allowed
              Open

                          $accountRecordModel = Vtiger_Record_Model::getInstanceById($relatedRecord, $sourceModule);

              Spaces must be used to indent lines; tabs are not allowed
              Open

                  }

              Spaces must be used to indent lines; tabs are not allowed
              Open

                                  'id' => $importer->primaryKey(10),

              Spaces must be used to indent lines; tabs are not allowed
              Open

                              ],

              Spaces must be used to indent lines; tabs are not allowed
              Open

                              'charset' => 'utf8',

              Spaces must be used to indent lines; tabs are not allowed
              Open

                              'columns' => [

              Spaces must be used to indent lines; tabs are not allowed
              Open

                                  'invtype' => $importer->stringType(30)->notNull(),

              Spaces must be used to indent lines; tabs are not allowed
              Open

                              'columns' => [

              Spaces must be used to indent lines; tabs are not allowed
              Open

                          if (!$db->isTableExists($tableName)) {

              Spaces must be used to indent lines; tabs are not allowed
              Open

                  /**

              Spaces must be used to indent lines; tabs are not allowed
              Open

                          $data['comment1'] = $recordModel->get('description');

              Spaces must be used to indent lines; tabs are not allowed
              Open

                          foreach ($autoCompleteField as $field) {

              Spaces must be used to indent lines; tabs are not allowed
              Open

                          $recordName = $accountRecordModel->getName();

              Spaces must be used to indent lines; tabs are not allowed
              Open

                          $recordName = $accountRecordModel->getName();

              Spaces must be used to indent lines; tabs are not allowed
              Open

                      return ['taxes' => $accountTaxes, 'name' => $recordName];

              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 loadRowData(int $recordId, array $params = []): 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 getAccountDiscount($relatedRecord)

              Spaces must be used to indent lines; tabs are not allowed
              Open

                      $recordName = '';

              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

                                  'columnname' => $importer->stringType(30)->notNull(),

              Spaces must be used to indent lines; tabs are not allowed
              Open

                          ],

              Spaces must be used to indent lines; tabs are not allowed
              Open

                              'charset' => 'utf8',

              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

                      $recordName = '';

              Spaces must be used to indent lines; tabs are not allowed
              Open

                      if (!empty($relatedRecord) && \App\Record::isExists($relatedRecord, $sourceModule) && ($taxField = current(Vtiger_Module_Model::getInstance($sourceModule)->getFieldsByUiType(303))) && $taxField->isActiveField()) {

              Spaces must be used to indent lines; tabs are not allowed
              Open

                   */

              Spaces must be used to indent lines; tabs are not allowed
              Open

                                  'id' => $importer->primaryKey(),

              Spaces must be used to indent lines; tabs are not allowed
              Open

                                  'label' => $importer->stringType(50)->notNull(),

              Spaces must be used to indent lines; tabs are not allowed
              Open

                                  'params' => $importer->text(),

              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['purchase'] = $fieldModel->getUITypeModel()->getValueForCurrency($recordModel->get($fieldModel->getName()), $currencyId);

              Spaces must be used to indent lines; tabs are not allowed
              Open

                              }

              Spaces must be used to indent lines; tabs are not allowed
              Open

                      $defaultTax = (new App\Db\Query())->from('a_#__taxes_global')->where(['status' => 0])->andWhere(['default' => 1])

              Spaces must be used to indent lines; tabs are not allowed
              Open

                   * @param int $relatedRecord Record ID

              Spaces must be used to indent lines; tabs are not allowed
              Open

                              'index' => [

              Spaces must be used to indent lines; tabs are not allowed
              Open

                          $this->getTableName(self::TABLE_POSTFIX_BASE) => [

              Spaces must be used to indent lines; tabs are not allowed
              Open

                                  'sequence' => $importer->integer(10)->unsigned()->notNull(),

              Spaces must be used to indent lines; tabs are not allowed
              Open

                          if (($fieldModel = $recordModel->getField('purchase')) && $fieldModel->isActiveField()) {

              Spaces must be used to indent lines; tabs are not allowed
              Open

                      $tables = [

              Spaces must be used to indent lines; tabs are not allowed
              Open

                                  ["{$dataTableName}_crmid_idx", 'crmid'],

              Spaces must be used to indent lines; tabs are not allowed
              Open

                                  'presence' => $importer->smallInteger(1)->unsigned()->notNull()->defaultValue(0),

              Spaces must be used to indent lines; tabs are not allowed
              Open

                              ],

              Spaces must be used to indent lines; tabs are not allowed
              Open

                   * @param array $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

                          }

              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

                      }

              Class name "Vtiger_Inventory_Model" is not in camel caps format
              Open

              class Vtiger_Inventory_Model

              There are no issues that match your filters.

              Category
              Status