YetiForceCompany/YetiForceCRM

View on GitHub
api/webservice/WebservicePremium/BaseModule/Hierarchy.php

Summary

Maintainability
B
5 hrs
Test Coverage
C
76%

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

    public function getRecords(\App\QueryGenerator $mainQueryGenerator, int $parentId, string $type = 'child'): void
    {
        if (0 === $this->limit || isset($this->recursion[$parentId][$type])) {
            return;
        }
Severity: Minor
Found in api/webservice/WebservicePremium/BaseModule/Hierarchy.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

Method getRecords has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getRecords(\App\QueryGenerator $mainQueryGenerator, int $parentId, string $type = 'child'): void
    {
        if (0 === $this->limit || isset($this->recursion[$parentId][$type])) {
            return;
        }
Severity: Minor
Found in api/webservice/WebservicePremium/BaseModule/Hierarchy.php - About 1 hr to fix

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

        public function get(): array
        {
            $parentId = \App\Record::getParentRecord($this->getUserCrmId());
            if (\in_array($this->getPermissionType(), [\Api\WebservicePremium\Privilege::ACCOUNTS_RELATED_RECORDS_IN_HIERARCHY, \Api\WebservicePremium\Privilege::ACCOUNTS_RELATED_RECORDS_AND_LOWER_IN_HIERARCHY])) {
                $fields = \App\Field::getRelatedFieldForModule($this->moduleName);
    Severity: Minor
    Found in api/webservice/WebservicePremium/BaseModule/Hierarchy.php - About 1 hr to fix

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

          public function get(): array
          {
              $parentId = \App\Record::getParentRecord($this->getUserCrmId());
              if (\in_array($this->getPermissionType(), [\Api\WebservicePremium\Privilege::ACCOUNTS_RELATED_RECORDS_IN_HIERARCHY, \Api\WebservicePremium\Privilege::ACCOUNTS_RELATED_RECORDS_AND_LOWER_IN_HIERARCHY])) {
                  $fields = \App\Field::getRelatedFieldForModule($this->moduleName);
      Severity: Minor
      Found in api/webservice/WebservicePremium/BaseModule/Hierarchy.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

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

          public function getRecords(\App\QueryGenerator $mainQueryGenerator, int $parentId, string $type = 'child'): void
          {
              if (0 === $this->limit || isset($this->recursion[$parentId][$type])) {
                  return;
              }

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

          public function getRecords(\App\QueryGenerator $mainQueryGenerator, int $parentId, string $type = 'child'): void

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

                      throw new \Api\Core\Exception('No hierarchy', 405);

      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 '45', column '14').
      Open

                  throw new \Api\Core\Exception('Not available for this type of user', 405);

      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 '102', column '26').
      Open

                  $queryGenerator = new \App\QueryGenerator($this->moduleName);

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

                          'name' => \App\Record::getLabel($parentId),

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

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

                  } else {
                      $this->records[$parentId] = [
                          'id' => $parentId,
                          'parent' => 0,
                          'name' => \App\Record::getLabel($parentId),

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

              } else {
                  $this->records[$parentId] = [
                      'id' => $parentId,
                      'name' => \App\Record::getLabel($parentId),
                  ];

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

              $parentId = \App\Record::getParentRecord($this->getUserCrmId());

      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\Field' in method 'get'.
      Open

                  $fields = \App\Field::getRelatedFieldForModule($this->moduleName);

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

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

                      'name' => \App\Record::getLabel($parentId),

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

              } else {
                  $queryGenerator->addCondition($this->childField, $parentId, 'eid');
              }

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

                      'name' => \App\Record::getLabel($id),

      StaticAccess

      Since: 1.4.0

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

      Example

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

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

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

                      } else {
                          $this->getRecords($mainQueryGenerator, $id, $type);
                      }

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

                      $this->getRecords($queryGenerator, $parentId, 'parent');

      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.

      Possibly zero references to use statement for classlike/namespace OA (\OpenApi\Annotations)
      Open

      use OpenApi\Annotations as OA;

      Call to method __construct from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
      Open

                  $queryGenerator = new \App\QueryGenerator($this->moduleName);

      Reference to instance property permissions from undeclared class \App\QueryGenerator
      Open

                  $queryGenerator->permissions = false;

      Call to method setFields from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
      Open

                  $queryGenerator->setFields(['id', $this->childField]);

      Call to method createQuery from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
      Open

              foreach ($queryGenerator->createQuery()->all() as $row) {

      Call to method addCondition from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
      Open

                  $queryGenerator->addCondition('id', $parentId, 'e');

      Call to method addCondition from undeclared class \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
      Open

                  $queryGenerator->addCondition($this->childField, $parentId, 'eid');

      Parameter $mainQueryGenerator has undeclared type \App\QueryGenerator (Did you mean class \Tests\App\QueryGenerator)
      Open

          public function getRecords(\App\QueryGenerator $mainQueryGenerator, int $parentId, string $type = 'child'): void

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

                  $id = $row['id'];

      ShortVariable

      Since: 0.2

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

      Example

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

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

      Spaces must be used for alignment; tabs are not allowed
      Open

           *            @OA\XmlContent(ref="#/components/schemas/BaseModule_Get_Hierarchy_Response"),

      Spaces must be used for alignment; tabs are not allowed
      Open

           *                description="Record details",

      Spaces must be used for alignment; tabs are not allowed
      Open

           *        security={{"basicAuth" : {}, "ApiKeyAuth" : {}, "token" : {}}},

      Spaces must be used for alignment; tabs are not allowed
      Open

           *        type="object",

      Spaces must be used for alignment; tabs are not allowed
      Open

           *                description="Record details",

      Spaces must be used for alignment; tabs are not allowed
      Open

           *        @OA\Response(response=405, description="`No hierarchy` OR `Not available for this type of user`",

      Spaces must be used for alignment; tabs are not allowed
      Open

           *        @OA\Parameter(name="moduleName", in="path", @OA\Schema(type="string"), description="Module name", required=true, example="Accounts"),

      Spaces must be used for alignment; tabs are not allowed
      Open

           *            @OA\JsonContent(ref="#/components/schemas/BaseModule_Get_Hierarchy_Response"),

      Spaces must be used for alignment; tabs are not allowed
      Open

           *        security={{"basicAuth" : {}, "ApiKeyAuth" : {}, "token" : {}}},

      Spaces must be used for alignment; tabs are not allowed
      Open

           *            @OA\XmlContent(ref="#/components/schemas/BaseModule_Get_Hierarchy_Response"),

      Spaces must be used for alignment; tabs are not allowed
      Open

           *            @OA\JsonContent(ref="#/components/schemas/Exception"),

      Spaces must be used for alignment; tabs are not allowed
      Open

           *        @OA\Property(property="status", type="integer", enum={0, 1}, description="A numeric value of 0 or 1 that indicates whether the communication is valid. 1 - success , 0 - error"),

      Spaces must be used for alignment; tabs are not allowed
      Open

           *            @OA\AdditionalProperties(

      Spaces must be used for alignment; tabs are not allowed
      Open

                  }

      Spaces must be used for alignment; tabs are not allowed
      Open

                  ];

      Spaces must be used for alignment; tabs are not allowed
      Open

                  if ($this->findId && $this->findId === $id) {

      Spaces must be used for alignment; tabs are not allowed
      Open

           *        @OA\Parameter(name="X-ENCRYPTED", in="header", @OA\Schema(ref="#/components/schemas/Header-Encrypted"), required=true),

      Spaces must be used for alignment; tabs are not allowed
      Open

           *            @OA\XmlContent(ref="#/components/schemas/Exception"),

      Spaces must be used for alignment; tabs are not allowed
      Open

           * ),

      Spaces must be used for alignment; tabs are not allowed
      Open

           *        schema="BaseModule_Get_Hierarchy_Response",

      Spaces must be used for alignment; tabs are not allowed
      Open

           *        title="Base module - Hierarchy response schema",

      Spaces must be used for alignment; tabs are not allowed
      Open

           *            description="Records",

      Spaces must be used for alignment; tabs are not allowed
      Open

           *                 @OA\Property(property="parent", type="integer", example=0),

      Spaces must be used for alignment; tabs are not allowed
      Open

           *                 @OA\Property(property="name", type="string", example="YetiForce S.A."),

      Spaces must be used for alignment; tabs are not allowed
      Open

           *             ),

      Spaces must be used for alignment; tabs are not allowed
      Open

           *        ),

      Spaces must be used for alignment; tabs are not allowed
      Open

                      $this->limit = 0;

      Spaces must be used for alignment; tabs are not allowed
      Open

                          $this->getRecords($mainQueryGenerator, $row[$this->childField], $type);

      Spaces must be used for alignment; tabs are not allowed
      Open

                          $this->getRecords($mainQueryGenerator, $id, $type);

      Spaces must be used for alignment; tabs are not allowed
      Open

           *        path="/webservice/WebservicePremium/{moduleName}/Hierarchy",

      Spaces must be used for alignment; tabs are not allowed
      Open

           *        description="Hierarchy of records",

      Spaces must be used for alignment; tabs are not allowed
      Open

           *        tags={"BaseModule"},

      Spaces must be used for alignment; tabs are not allowed
      Open

           *            description="Records",

      Spaces must be used for alignment; tabs are not allowed
      Open

           *    ),

      Spaces must be used for alignment; tabs are not allowed
      Open

                  }

      Spaces must be used for alignment; tabs are not allowed
      Open

              $this->recursion[$parentId][$type] = true;

      Spaces must be used for alignment; tabs are not allowed
      Open

                      if ('parent' === $type) {

      Spaces must be used for alignment; tabs are not allowed
      Open

           *        @OA\Parameter(name="moduleName", in="path", @OA\Schema(type="string"), description="Module name", required=true, example="Accounts"),

      Spaces must be used for alignment; tabs are not allowed
      Open

           *        @OA\Response(response=200, description="Records hierarchy details",

      Spaces must be used for alignment; tabs are not allowed
      Open

           *        ),

      Spaces must be used for alignment; tabs are not allowed
      Open

           *            type="object",

      Spaces must be used for alignment; tabs are not allowed
      Open

          {

      Spaces must be used for alignment; tabs are not allowed
      Open

                  if (!isset($fields[$this->moduleName])) {

      Spaces must be used for alignment; tabs are not allowed
      Open

                  $queryGenerator = new \App\QueryGenerator($this->moduleName);

      Spaces must be used for alignment; tabs are not allowed
      Open

                  $queryGenerator->setFields(['id', $this->childField]);

      Spaces must be used for alignment; tabs are not allowed
      Open

           * @param string              $type

      Spaces must be used for alignment; tabs are not allowed
      Open

              } else {

      Spaces must be used for alignment; tabs are not allowed
      Open

                      } else {

      Spaces must be used for alignment; tabs are not allowed
      Open

           * @OA\Schema(

      Spaces must be used for alignment; tabs are not allowed
      Open

           *            property="result",

      Spaces must be used for alignment; tabs are not allowed
      Open

           *        ),

      Spaces must be used for alignment; tabs are not allowed
      Open

          public function get(): array

      Spaces must be used for alignment; tabs are not allowed
      Open

              } else {

      Spaces must be used for alignment; tabs are not allowed
      Open

                  $this->records[$parentId] = [

      Spaces must be used for alignment; tabs are not allowed
      Open

                      'id' => $parentId,

      Spaces must be used for alignment; tabs are not allowed
      Open

           *

      Spaces must be used for alignment; tabs are not allowed
      Open

                  return;

      Spaces must be used for alignment; tabs are not allowed
      Open

              }

      Spaces must be used for alignment; tabs are not allowed
      Open

                  if (!empty($row[$this->childField])) {

      Spaces must be used for alignment; tabs are not allowed
      Open

           *            type="object",

      Spaces must be used for alignment; tabs are not allowed
      Open

           *                type="object",

      Spaces must be used for alignment; tabs are not allowed
      Open

                  $this->childField = $field['fieldname'];

      Spaces must be used for alignment; tabs are not allowed
      Open

                  } else {

      Spaces must be used for alignment; tabs are not allowed
      Open

              if (0 === $this->limit || isset($this->recursion[$parentId][$type])) {

      Spaces must be used for alignment; tabs are not allowed
      Open

           *        summary="Gets records hierarchy",

      Spaces must be used for alignment; tabs are not allowed
      Open

           *        @OA\Response(response=200, description="Records hierarchy details",

      Spaces must be used for alignment; tabs are not allowed
      Open

           *            @OA\JsonContent(ref="#/components/schemas/BaseModule_Get_Hierarchy_Response"),

      Spaces must be used for alignment; tabs are not allowed
      Open

           *        schema="BaseModule_Get_Hierarchy_Response",

      Spaces must be used for alignment; tabs are not allowed
      Open

           *                 @OA\Property(property="id", type="integer", example=117),

      Spaces must be used for alignment; tabs are not allowed
      Open

           *                 @OA\Property(property="name", type="string", example="YetiForce S.A."),

      Spaces must be used for alignment; tabs are not allowed
      Open

                      throw new \Api\Core\Exception('No hierarchy', 405);

      Spaces must be used for alignment; tabs are not allowed
      Open

                          'name' => \App\Record::getLabel($parentId),

      Spaces must be used for alignment; tabs are not allowed
      Open

                  $queryGenerator->addCondition('id', $parentId, 'e');

      Spaces must be used for alignment; tabs are not allowed
      Open

              foreach ($queryGenerator->createQuery()->all() as $row) {

      Spaces must be used for alignment; tabs are not allowed
      Open

                  if (isset($this->records[$id])) {

      Spaces must be used for alignment; tabs are not allowed
      Open

                  }

      Spaces must be used for alignment; tabs are not allowed
      Open

           *        tags={"BaseModule"},

      Spaces must be used for alignment; tabs are not allowed
      Open

           *            @OA\XmlContent(ref="#/components/schemas/Exception"),

      Spaces must be used for alignment; tabs are not allowed
      Open

           *        title="Base module - Hierarchy response schema",

      Spaces must be used for alignment; tabs are not allowed
      Open

              if (\in_array($this->getPermissionType(), [\Api\WebservicePremium\Privilege::ACCOUNTS_RELATED_RECORDS_IN_HIERARCHY, \Api\WebservicePremium\Privilege::ACCOUNTS_RELATED_RECORDS_AND_LOWER_IN_HIERARCHY])) {

      Spaces must be used for alignment; tabs are not allowed
      Open

                  $field = $fields[$this->moduleName];

      Spaces must be used for alignment; tabs are not allowed
      Open

                          'id' => $parentId,

      Spaces must be used for alignment; tabs are not allowed
      Open

                      'name' => \App\Record::getLabel($parentId),

      Spaces must be used for alignment; tabs are not allowed
      Open

          }

      Spaces must be used for alignment; tabs are not allowed
      Open

           * @param \App\QueryGenerator $mainQueryGenerator

      Spaces must be used for alignment; tabs are not allowed
      Open

           */

      Spaces must be used for alignment; tabs are not allowed
      Open

                  $queryGenerator->addCondition($this->childField, $parentId, 'eid');

      Spaces must be used for alignment; tabs are not allowed
      Open

                      continue;

      Spaces must be used for alignment; tabs are not allowed
      Open

           *        description="Hierarchy of records",

      Spaces must be used for alignment; tabs are not allowed
      Open

           *            @OA\JsonContent(ref="#/components/schemas/Exception"),

      Spaces must be used for alignment; tabs are not allowed
      Open

           *        type="object",

      Spaces must be used for alignment; tabs are not allowed
      Open

           *            @OA\AdditionalProperties(

      Spaces must be used for alignment; tabs are not allowed
      Open

           *                 @OA\Property(property="id", type="integer", example=117),

      Spaces must be used for alignment; tabs are not allowed
      Open

              $parentId = \App\Record::getParentRecord($this->getUserCrmId());

      Spaces must be used for alignment; tabs are not allowed
      Open

           * @param int                 $parentId

      Spaces must be used for alignment; tabs are not allowed
      Open

              if ('parent' === $type) {

      Spaces must be used for alignment; tabs are not allowed
      Open

                          $this->getRecords($mainQueryGenerator, $row[$this->childField], 'child');

      Spaces must be used for alignment; tabs are not allowed
      Open

           *        summary="Gets records hierarchy",

      Spaces must be used for alignment; tabs are not allowed
      Open

           *        @OA\Parameter(name="X-ENCRYPTED", in="header", @OA\Schema(ref="#/components/schemas/Header-Encrypted"), required=true),

      Spaces must be used for alignment; tabs are not allowed
      Open

           *        @OA\Property(property="status", type="integer", enum={0, 1}, description="A numeric value of 0 or 1 that indicates whether the communication is valid. 1 - success , 0 - error"),

      Spaces must be used for alignment; tabs are not allowed
      Open

           */

      Spaces must be used for alignment; tabs are not allowed
      Open

                      $this->getRecords($queryGenerator, $parentId, 'parent');

      Spaces must be used for alignment; tabs are not allowed
      Open

                          'parent' => 0,

      Spaces must be used for alignment; tabs are not allowed
      Open

           *

      Spaces must be used for alignment; tabs are not allowed
      Open

              --$this->limit;

      Spaces must be used for alignment; tabs are not allowed
      Open

              $queryGenerator = clone $mainQueryGenerator;

      Spaces must be used for alignment; tabs are not allowed
      Open

                      'parent' => $row[$this->childField],

      Spaces must be used for alignment; tabs are not allowed
      Open

           *    ),

      Spaces must be used for alignment; tabs are not allowed
      Open

                  $queryGenerator->permissions = false;

      Spaces must be used for alignment; tabs are not allowed
      Open

              }

      Spaces must be used for alignment; tabs are not allowed
      Open

                      'id' => $id,

      Spaces must be used for alignment; tabs are not allowed
      Open

                  ];

      Spaces must be used for alignment; tabs are not allowed
      Open

                      return;

      Spaces must be used for alignment; tabs are not allowed
      Open

                      }

      Spaces must be used for alignment; tabs are not allowed
      Open

           *        ),

      Spaces must be used for alignment; tabs are not allowed
      Open

           *        @OA\Response(response=405, description="`No hierarchy` OR `Not available for this type of user`",

      Spaces must be used for alignment; tabs are not allowed
      Open

           *        ),

      Spaces must be used for alignment; tabs are not allowed
      Open

           *        ),

      Spaces must be used for alignment; tabs are not allowed
      Open

           *        @OA\Property(

      Spaces must be used for alignment; tabs are not allowed
      Open

           *        @OA\Property(

      Spaces must be used for alignment; tabs are not allowed
      Open

           *            property="result",

      Spaces must be used for alignment; tabs are not allowed
      Open

           *                type="object",

      Spaces must be used for alignment; tabs are not allowed
      Open

                  $fields = \App\Field::getRelatedFieldForModule($this->moduleName);

      Spaces must be used for alignment; tabs are not allowed
      Open

                  if (\Api\WebservicePremium\Privilege::ACCOUNTS_RELATED_RECORDS_IN_HIERARCHY === $this->getPermissionType()) {

      Spaces must be used for alignment; tabs are not allowed
      Open

          /**

      Spaces must be used for alignment; tabs are not allowed
      Open

                  $id = $row['id'];

      Spaces must be used for alignment; tabs are not allowed
      Open

                  $this->getRecords($queryGenerator, $parentId);

      Spaces must be used for alignment; tabs are not allowed
      Open

           * Get records in hierarchy.

      Spaces must be used for alignment; tabs are not allowed
      Open

                  }

      Spaces must be used for alignment; tabs are not allowed
      Open

                  $this->records[$id] = [

      Spaces must be used for alignment; tabs are not allowed
      Open

           *                 @OA\Property(property="parent", type="integer", example=0),

      Spaces must be used for alignment; tabs are not allowed
      Open

                      $this->records[$parentId] = [

      Spaces must be used for alignment; tabs are not allowed
      Open

                      ];

      Spaces must be used for alignment; tabs are not allowed
      Open

          {

      Spaces must be used for alignment; tabs are not allowed
      Open

              }

      Spaces must be used for alignment; tabs are not allowed
      Open

                      'name' => \App\Record::getLabel($id),

      Spaces must be used for alignment; tabs are not allowed
      Open

                  }

      Spaces must be used for alignment; tabs are not allowed
      Open

           *             ),

      Spaces must be used for alignment; tabs are not allowed
      Open

              }

      Spaces must be used for alignment; tabs are not allowed
      Open

              return $this->records;

      Spaces must be used for alignment; tabs are not allowed
      Open

           * @return void

      Spaces must be used for alignment; tabs are not allowed
      Open

          public function getRecords(\App\QueryGenerator $mainQueryGenerator, int $parentId, string $type = 'child'): void

      Spaces must be used for alignment; tabs are not allowed
      Open

          }

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

          public $limit = 20;

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

          /** {@inheritdoc}  */

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

           * Get method - Gets records hierarchy.

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

           *        path="/webservice/WebservicePremium/{moduleName}/Hierarchy",

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

          public $moduleName;

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

              parent::checkPermission();

      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

           *

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

          /**

      Line exceeds 120 characters; contains 145 characters
      Open

           *        @OA\Parameter(name="moduleName", in="path", @OA\Schema(type="string"), description="Module name", required=true, example="Accounts"),

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

          /** {@inheritdoc}  */

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

              if (1 === $this->getPermissionType()) {

      Line exceeds 120 characters; contains 131 characters
      Open

           *        @OA\Parameter(name="X-ENCRYPTED", in="header", @OA\Schema(ref="#/components/schemas/Header-Encrypted"), required=true),

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

          public $recursion = [];

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

          }

      Line exceeds 120 characters; contains 189 characters
      Open

           *        @OA\Property(property="status", type="integer", enum={0, 1}, description="A numeric value of 0 or 1 that indicates whether the communication is valid. 1 - success , 0 - error"),

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

          public $allowedMethod = ['GET'];

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

          /** @var int Recursion limit */

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

          public $findId = 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

          /** @var string Module name */

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

          public $mainField;

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

          public $childField;

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

          public $records = [];

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

           * @throws \Api\Core\Exception

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

          /** @var bool|int Search id in the hierarchy */

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

          {

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

           * @OA\Get(

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

                  throw new \Api\Core\Exception('Not available for this type of user', 405);

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

          protected function checkPermission(): void

      Line exceeds 120 characters; contains 121 characters
      Open

                  if (\Api\WebservicePremium\Privilege::ACCOUNTS_RELATED_RECORDS_IN_HIERARCHY === $this->getPermissionType()) {

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

              $this->moduleName = $this->controller->request->get('module');

      Line exceeds 120 characters; contains 210 characters
      Open

              if (\in_array($this->getPermissionType(), [\Api\WebservicePremium\Privilege::ACCOUNTS_RELATED_RECORDS_IN_HIERARCHY, \Api\WebservicePremium\Privilege::ACCOUNTS_RELATED_RECORDS_AND_LOWER_IN_HIERARCHY])) {

      There are no issues that match your filters.

      Category
      Status