YetiForceCompany/YetiForceCRM

View on GitHub
app/FieldsDependency.php

Summary

Maintainability
B
6 hrs
Test Coverage
F
40%

Function getByModule has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    public static function getByModule(int $tabId, ?int $gui = null): array
    {
        if (Cache::has('FieldsDependency', $tabId)) {
            $fields = Cache::get('FieldsDependency', $tabId);
        } else {
Severity: Minor
Found in app/FieldsDependency.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 getByRecordModel has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

    public static function getByRecordModel(string $view, \Vtiger_Record_Model $recordModel, bool $cache = true): array
    {
        $cacheKey = $view . $recordModel->getId();
        if ($cache && isset(self::$recordModelCache[$cacheKey])) {
            return self::$recordModelCache[$cacheKey];
Severity: Minor
Found in app/FieldsDependency.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 getByModule has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function getByModule(int $tabId, ?int $gui = null): array
    {
        if (Cache::has('FieldsDependency', $tabId)) {
            $fields = Cache::get('FieldsDependency', $tabId);
        } else {
Severity: Minor
Found in app/FieldsDependency.php - About 1 hr to fix

    Method getByRecordModel has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public static function getByRecordModel(string $view, \Vtiger_Record_Model $recordModel, bool $cache = true): array
        {
            $cacheKey = $view . $recordModel->getId();
            if ($cache && isset(self::$recordModelCache[$cacheKey])) {
                return self::$recordModelCache[$cacheKey];
    Severity: Minor
    Found in app/FieldsDependency.php - About 1 hr to fix

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

          public static function getByRecordModel(string $view, \Vtiger_Record_Model $recordModel, bool $cache = true): array
          {
              $cacheKey = $view . $recordModel->getId();
              if ($cache && isset(self::$recordModelCache[$cacheKey])) {
                  return self::$recordModelCache[$cacheKey];
      Severity: Minor
      Found in app/FieldsDependency.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 static function getByRecordModel(string $view, \Vtiger_Record_Model $recordModel, bool $cache = true): array
      Severity: Critical
      Found in app/FieldsDependency.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

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

          public static function getByModule(int $tabId, ?int $gui = null): array
      Severity: Critical
      Found in app/FieldsDependency.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

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

                  $dataReader = (new \App\Db\Query())->from('s_#__fields_dependency')->where(['status' => 0, 'tabid' => $tabId])
      Severity: Minor
      Found in app/FieldsDependency.php by phpmd

      MissingImport

      Since: 2.7.0

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

      Example

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

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

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

          public static function getByRecordModel(string $view, \Vtiger_Record_Model $recordModel, bool $cache = true): array
      Severity: Minor
      Found in app/FieldsDependency.php by phpmd

      BooleanArgumentFlag

      Since: 1.4.0

      A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

      Example

      class Foo {
          public function bar($flag = true) {
          }
      }

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

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

                  $fields = Cache::get('FieldsDependency', $tabId);
      Severity: Minor
      Found in app/FieldsDependency.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 'getByModule'.
      Open

                  Cache::save('FieldsDependency', $tabId, $fields);
      Severity: Minor
      Found in app/FieldsDependency.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 getByRecordModel uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

                      } else {
                          $return[$status]['backend'] = array_merge($return[$status]['backend'], $row['fields']);
                      }
      Severity: Minor
      Found in app/FieldsDependency.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 'getByModule'.
      Open

              if (Cache::has('FieldsDependency', $tabId)) {
      Severity: Minor
      Found in app/FieldsDependency.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\Json' in method 'getByModule'.
      Open

                      $row['conditionsFields'] = Json::decode($row['conditionsFields']) ?? [];
      Severity: Minor
      Found in app/FieldsDependency.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\Json' in method 'getByModule'.
      Open

                      $views = Json::decode($row['views']) ?? [];
      Severity: Minor
      Found in app/FieldsDependency.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\Json' in method 'getByModule'.
      Open

                      $row['fields'] = Json::decode($row['fields']) ?? [];
      Severity: Minor
      Found in app/FieldsDependency.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\Json' in method 'getByModule'.
      Open

                      $row['conditions'] = Json::decode($row['conditions']) ?? [];
      Severity: Minor
      Found in app/FieldsDependency.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\Condition' in method 'getByRecordModel'.
      Open

                      $status = (!$row['conditions'] || Condition::checkConditions($row['conditions'], $recordModel)) ? 'show' : 'hide';
      Severity: Minor
      Found in app/FieldsDependency.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 getByModule 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('s_#__fields_dependency')->where(['status' => 0, 'tabid' => $tabId])
                      ->createCommand()->query();
                  while ($row = $dataReader->read()) {
      Severity: Minor
      Found in app/FieldsDependency.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

      Define a constant instead of duplicating this literal "mandatory" 10 times.
      Open

                      $row['mandatory'] = (int) $row['mandatory'];
      Severity: Critical
      Found in app/FieldsDependency.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 "backend" 4 times.
      Open

                  'show' => ['backend' => [], 'frontend' => [], 'mandatory' => []],
      Severity: Critical
      Found in app/FieldsDependency.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 "frontend" 4 times.
      Open

                  'show' => ['backend' => [], 'frontend' => [], 'mandatory' => []],
      Severity: Critical
      Found in app/FieldsDependency.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 "FieldsDependency" 3 times.
      Open

              if (Cache::has('FieldsDependency', $tabId)) {
      Severity: Critical
      Found in app/FieldsDependency.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 "fields" 6 times.
      Open

                      $row['fields'] = Json::decode($row['fields']) ?? [];
      Severity: Critical
      Found in app/FieldsDependency.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 "conditionsFields" 6 times.
      Open

                      $row['conditionsFields'] = Json::decode($row['conditionsFields']) ?? [];
      Severity: Critical
      Found in app/FieldsDependency.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 "conditions" 4 times.
      Open

                      $row['conditions'] = Json::decode($row['conditions']) ?? [];
      Severity: Critical
      Found in app/FieldsDependency.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.

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

                  $fields = Cache::get('FieldsDependency', $tabId);
      Severity: Minor
      Found in app/FieldsDependency.php by phan

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

                  Cache::save('FieldsDependency', $tabId, $fields);
      Severity: Minor
      Found in app/FieldsDependency.php by phan

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

                  $dataReader = (new \App\Db\Query())->from('s_#__fields_dependency')->where(['status' => 0, 'tabid' => $tabId])
      Severity: Critical
      Found in app/FieldsDependency.php by phan

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

              if (Cache::has('FieldsDependency', $tabId)) {
      Severity: Minor
      Found in app/FieldsDependency.php by phan

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

          /**
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

           * @var array
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

              if (isset($gui)) {
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

           * @param string               $view
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

           * @param \Vtiger_Record_Model $recordModel
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

                      if (self::GUI_FRONTEND === $row['gui']) {
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

           * @var int
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

           *
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

           */
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

                          $fields[$view][] = $row;
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

              return $fields;
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

          /**
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

           */
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

           *
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

                  $dataReader = (new \App\Db\Query())->from('s_#__fields_dependency')->where(['status' => 0, 'tabid' => $tabId])
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

      Line exceeds 120 characters; contains 130 characters
      Open

                      $status = (!$row['conditions'] || Condition::checkConditions($row['conditions'], $recordModel)) ? 'show' : 'hide';
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

                      }
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

           * @var array Views labels
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

           */
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

           * Get the dependency list for module.
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

                      foreach ($views as $view) {
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

                  foreach ($fields as $view => $rows) {
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

           * @param bool                 $cache
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

           *
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

                  $fields = [];
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

                      $views = Json::decode($row['views']) ?? [];
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

          }
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

           *
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

           */
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

                  'show' => ['backend' => [], 'frontend' => [], 'mandatory' => []],
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

                          $return[$status]['mandatory'] = array_merge($return[$status]['mandatory'], $row['fields']);
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

                          $return['mandatory'] = array_merge($return['mandatory'], $row['fields']);
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

                      $return['conditionsFields'] = array_merge($return['conditionsFields'], $row['conditionsFields']);
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

              return self::$recordModelCache[$cacheKey] = $return;
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

              'Edit' => 'LBL_VIEW_EDIT',
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

           * Cache variable for list of fields to hide for a record in a view.
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

           * @param int      $tabId
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

              }
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

                              unset($fields[$view][$key]);
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

          }
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

           *
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

              $fields = self::getByModule($recordModel->getModule()->getId());
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

                      $status = (!$row['conditions'] || Condition::checkConditions($row['conditions'], $recordModel)) ? 'show' : 'hide';
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

                          $return[$status]['backend'] = array_merge($return[$status]['backend'], $row['fields']);
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

           * @param int|null $gui
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

                      ->createCommand()->query();
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

                      $row['conditions'] = Json::decode($row['conditions']) ?? [];
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

                  }
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

           * @return array
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

          public static function getByModule(int $tabId, ?int $gui = null): array
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

          {
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

                      foreach ($rows as $key => $row) {
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

                          }
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

                      }
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

              $cacheKey = $view . $recordModel->getId();
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

              $return = [
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

              ];
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

                  foreach ($fields[$view] as $row) {
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

                      if (1 === $row['mandatory']) {
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

           */
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

          public static $recordModelCache = [];
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

           * @return array
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

                  $fields = Cache::get('FieldsDependency', $tabId);
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

                      $row['conditionsFields'] = Json::decode($row['conditionsFields']) ?? [];
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

                  Cache::save('FieldsDependency', $tabId, $fields);
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

           *
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

              }
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

                  'conditionsFields' => [],
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

              if ($fields && isset($fields[$view])) {
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

              'Create' => 'LBL_VIEW_CREATE',
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

          ];
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

          /**
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

          /**
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

          /**
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

          {
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

                  'hide' => ['backend' => [], 'frontend' => [], 'mandatory' => []],
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

              'QuickCreate' => 'LBL_QUICK_CREATE',
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

           * @var int
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

      Line exceeds 120 characters; contains 122 characters
      Open

                  $dataReader = (new \App\Db\Query())->from('s_#__fields_dependency')->where(['status' => 0, 'tabid' => $tabId])
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

                      $row['fields'] = Json::decode($row['fields']) ?? [];
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

                  }
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

           * Get the list of fields to hide for a record in a view.
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

          public static function getByRecordModel(string $view, \Vtiger_Record_Model $recordModel, bool $cache = true): array
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

              'Detail' => 'LBL_VIEW_DETAIL',
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

              'QuickEdit' => 'LBL_QUICK_EDIT',
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

           */
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

           * @see FieldsDependency::getByRecordModel()
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

                      $row['gui'] = (int) $row['gui'];
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

                  }
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

          public const GUI_FRONTEND = 1;
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

           *
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

              if (Cache::has('FieldsDependency', $tabId)) {
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

                  while ($row = $dataReader->read()) {
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

                      }
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

              }
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

          public const GUI_BACKEND = 0;
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

          /**
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

              } else {
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

                      $row['mandatory'] = (int) $row['mandatory'];
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

              }
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

              if ($cache && isset(self::$recordModelCache[$cacheKey])) {
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

                          $return[$status]['frontend'] = array_merge($return[$status]['frontend'], $row['fields']);
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

                      } else {
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

          const VIEWS = [
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

                      unset($row['views']);
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

                      }
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

                          if ($gui !== $row['gui']) {
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

           * @see FieldsDependency::$recordModelCache
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

                  return self::$recordModelCache[$cacheKey];
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

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

                  'mandatory' => [],
      Severity: Minor
      Found in app/FieldsDependency.php by phpcodesniffer

      There are no issues that match your filters.

      Category
      Status