mambax7/extgallery

View on GitHub
class/NestedTree.php

Summary

Maintainability
B
5 hrs
Test Coverage

Function getDescendants has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    public function getDescendants($id = 0, $includeSelf = false, $childrenOnly = false)
    {
        $idField = $this->fields['id'];

        $node = $this->getNode($id);
Severity: Minor
Found in class/NestedTree.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 getDescendants has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function getDescendants($id = 0, $includeSelf = false, $childrenOnly = false)
    {
        $idField = $this->fields['id'];

        $node = $this->getNode($id);
Severity: Minor
Found in class/NestedTree.php - About 1 hr to fix

    Method __construct has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        public function __construct(\XoopsDatabase $db, $table, $idField, $parentField, $sortField)
    Severity: Minor
    Found in class/NestedTree.php - About 35 mins to fix

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

          public function numDescendants($id)
          {
              if (0 == $id) {
                  $query  = \sprintf('SELECT COUNT(*) AS num_descendants FROM `%s`', $this->table);
                  $result = $this->db->query($query);
      Severity: Minor
      Found in class/NestedTree.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 getPath has a boolean flag argument $includeSelf, which is a certain sign of a Single Responsibility Principle violation.
      Open

          public function getPath($id = 0, $includeSelf = false)
      Severity: Minor
      Found in class/NestedTree.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

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

          public function getDescendants($id = 0, $includeSelf = false, $childrenOnly = false)
      Severity: Minor
      Found in class/NestedTree.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

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

          public function getDescendants($id = 0, $includeSelf = false, $childrenOnly = false)
      Severity: Minor
      Found in class/NestedTree.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

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

          public function getChildren($id = 0, $includeSelf = false)
      Severity: Minor
      Found in class/NestedTree.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

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

              } else {
                  $query = \sprintf('SELECT * FROM `%s` WHERE nleft < %d AND nright > %d ORDER BY nlevel', $this->table, $node['nleft'], $node['nright']);
              }
      Severity: Minor
      Found in class/NestedTree.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 getDescendants uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

              } else {
                  if ($nleft > 0 && $includeSelf) {
                      $query = \sprintf('SELECT * FROM `%s` WHERE nleft >= %d AND nright <= %d ORDER BY nleft', $this->table, $nleft, $nright);
                  } else {
                      if ($nleft > 0) {
      Severity: Minor
      Found in class/NestedTree.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 numDescendants uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

              } else {
                  $node = $this->getNode($id);
                  if (!null === $node) {
                      return ($node['nright'] - $node['nleft'] - 1) / 2;
                  }
      Severity: Minor
      Found in class/NestedTree.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 getDescendants uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

                  } else {
                      $query = \sprintf('SELECT * FROM `%s` WHERE `%s` = %d ORDER BY nleft', $this->table, $this->fields['parent'], $parent_id);
                  }
      Severity: Minor
      Found in class/NestedTree.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 getDescendants uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

              } else {
                  $nleft     = $node['nleft'];
                  $nright    = $node['nright'];
                  $parent_id = $node[$this->fields['id']];
              }
      Severity: Minor
      Found in class/NestedTree.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 getDescendants uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

                  } else {
                      if ($nleft > 0) {
                          $query = \sprintf('SELECT * FROM `%s` WHERE nleft > %d AND nright < %d ORDER BY nleft', $this->table, $nleft, $nright);
                      } else {
                          $query = \sprintf('SELECT * FROM `%s` ORDER BY nleft', $this->table);
      Severity: Minor
      Found in class/NestedTree.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 getDescendants uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
      Open

                      } else {
                          $query = \sprintf('SELECT * FROM `%s` ORDER BY nleft', $this->table);
                      }
      Severity: Minor
      Found in class/NestedTree.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 unused local variables such as '$level'.
      Open

              $level = 0; // need a variable to hold the running level tally
      Severity: Minor
      Found in class/NestedTree.php by phpmd

      UnusedLocalVariable

      Since: 0.2

      Detects when a local variable is declared and/or assigned, but not used.

      Example

      class Foo {
          public function doSomething()
          {
              $i = 5; // Unused
          }
      }

      Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

      Avoid unused local variables such as '$idField'.
      Open

              $idField     = $this->fields['id'];
      Severity: Minor
      Found in class/NestedTree.php by phpmd

      UnusedLocalVariable

      Since: 0.2

      Detects when a local variable is declared and/or assigned, but not used.

      Example

      class Foo {
          public function doSomething()
          {
              $i = 5; // Unused
          }
      }

      Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

      Avoid unused local variables such as '$parentField'.
      Open

              $parentField = $this->fields['parent'];
      Severity: Minor
      Found in class/NestedTree.php by phpmd

      UnusedLocalVariable

      Since: 0.2

      Detects when a local variable is declared and/or assigned, but not used.

      Example

      class Foo {
          public function doSomething()
          {
              $i = 5; // Unused
          }
      }

      Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

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

          public function _generateTreeData(&$arr, $id, $level, &$n)
          {
              $arr[$id]['nlevel'] = $level;
              $arr[$id]['nleft']  = ++$n;
      
      
      Severity: Major
      Found in class/NestedTree.php and 1 other location - About 1 hr to fix
      class/CategoryHandler.php on lines 544..555

      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

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

          public $db;
      Severity: Minor
      Found in class/NestedTree.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

          public function numChildren($id)
      Severity: Minor
      Found in class/NestedTree.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

          public function getPath($id = 0, $includeSelf = false)
      Severity: Minor
      Found in class/NestedTree.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 $n. Configured minimum length is 3.
      Open

              $n     = 0; // need a variable to hold the running n tally
      Severity: Minor
      Found in class/NestedTree.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

      The parameter $descendant_id is not named in camelCase.
      Open

          public function isDescendantOf($descendant_id, $ancestor_id)
          {
              $node = $this->getNode($ancestor_id);
              if (null === $node) {
                  return false;
      Severity: Minor
      Found in class/NestedTree.php by phpmd

      CamelCaseParameterName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name parameters.

      Example

      class ClassName {
          public function doSomething($user_name) {
          }
      }

      Source

      The parameter $child_id is not named in camelCase.
      Open

          public function isChildOf($child_id, $parent_id)
          {
              $query = \sprintf('SELECT COUNT(*) AS is_child FROM `%s` WHERE `%s` = %d AND %s = %d', $this->table, $this->fields['id'], $child_id, $this->fields['parent'], $parent_id);
      
              $result = $this->db->query($query);
      Severity: Minor
      Found in class/NestedTree.php by phpmd

      CamelCaseParameterName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name parameters.

      Example

      class ClassName {
          public function doSomething($user_name) {
          }
      }

      Source

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

          public function _generateTreeData(&$arr, $id, $level, &$n)
      Severity: Minor
      Found in class/NestedTree.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

      The parameter $ancestor_id is not named in camelCase.
      Open

          public function isDescendantOf($descendant_id, $ancestor_id)
          {
              $node = $this->getNode($ancestor_id);
              if (null === $node) {
                  return false;
      Severity: Minor
      Found in class/NestedTree.php by phpmd

      CamelCaseParameterName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name parameters.

      Example

      class ClassName {
          public function doSomething($user_name) {
          }
      }

      Source

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

          public function numLeef($id)
      Severity: Minor
      Found in class/NestedTree.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

          public function __construct(\XoopsDatabase $db, $table, $idField, $parentField, $sortField)
      Severity: Minor
      Found in class/NestedTree.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

          public function _generateTreeData(&$arr, $id, $level, &$n)
      Severity: Minor
      Found in class/NestedTree.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

          public function getDescendants($id = 0, $includeSelf = false, $childrenOnly = false)
      Severity: Minor
      Found in class/NestedTree.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

          public function getChildren($id = 0, $includeSelf = false)
      Severity: Minor
      Found in class/NestedTree.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

          public function getNode($id)
      Severity: Minor
      Found in class/NestedTree.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

      The parameter $parent_id is not named in camelCase.
      Open

          public function isChildOf($child_id, $parent_id)
          {
              $query = \sprintf('SELECT COUNT(*) AS is_child FROM `%s` WHERE `%s` = %d AND %s = %d', $this->table, $this->fields['id'], $child_id, $this->fields['parent'], $parent_id);
      
              $result = $this->db->query($query);
      Severity: Minor
      Found in class/NestedTree.php by phpmd

      CamelCaseParameterName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name parameters.

      Example

      class ClassName {
          public function doSomething($user_name) {
          }
      }

      Source

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

          public function numDescendants($id)
      Severity: Minor
      Found in class/NestedTree.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

      Method name "_generateTreeData" should not be prefixed with an underscore to indicate visibility
      Open

          public function _generateTreeData(&$arr, $id, $level, &$n)
      Severity: Minor
      Found in class/NestedTree.php by phpcodesniffer

      Line exceeds 120 characters; contains 138 characters
      Open

                      $query = \sprintf('SELECT * FROM `%s` WHERE `%s` = %d ORDER BY nleft', $this->table, $this->fields['parent'], $parent_id);
      Severity: Minor
      Found in class/NestedTree.php by phpcodesniffer

      Line exceeds 120 characters; contains 148 characters
      Open

                  $query = \sprintf('SELECT * FROM `%s` WHERE nleft < %d AND nright > %d ORDER BY nlevel', $this->table, $node['nleft'], $node['nright']);
      Severity: Minor
      Found in class/NestedTree.php by phpcodesniffer

      Line exceeds 120 characters; contains 182 characters
      Open

                      $query = \sprintf('SELECT * FROM `%s` WHERE `%s` = %d OR %s = %d ORDER BY nleft', $this->table, $this->fields['id'], $parent_id, $this->fields['parent'], $parent_id);
      Severity: Minor
      Found in class/NestedTree.php by phpcodesniffer

      Line exceeds 120 characters; contains 178 characters
      Open

              $query = \sprintf('SELECT COUNT(*) AS is_child FROM `%s` WHERE `%s` = %d AND %s = %d', $this->table, $this->fields['id'], $child_id, $this->fields['parent'], $parent_id);
      Severity: Minor
      Found in class/NestedTree.php by phpcodesniffer

      Line exceeds 120 characters; contains 139 characters
      Open

                          $query = \sprintf('SELECT * FROM `%s` WHERE nleft > %d AND nright < %d ORDER BY nleft', $this->table, $nleft, $nright);
      Severity: Minor
      Found in class/NestedTree.php by phpcodesniffer

      Line exceeds 120 characters; contains 150 characters
      Open

                  $query = \sprintf('SELECT * FROM `%s` WHERE nleft <= %d AND nright >= %d ORDER BY nlevel', $this->table, $node['nleft'], $node['nright']);
      Severity: Minor
      Found in class/NestedTree.php by phpcodesniffer

      Line exceeds 120 characters; contains 189 characters
      Open

                  $query = \sprintf('UPDATE `%s` SET nlevel = %d, nleft = %d, nright = %d WHERE `%s` = %d', $this->table, $row['nlevel'], $row['nleft'], $row['nright'], $this->fields['id'], $id);
      Severity: Minor
      Found in class/NestedTree.php by phpcodesniffer

      Line exceeds 120 characters; contains 132 characters
      Open

              $query  = \sprintf('SELECT COUNT(*) AS num_children FROM `%s` WHERE `%s` = %d', $this->table, $this->fields['parent'], $id);
      Severity: Minor
      Found in class/NestedTree.php by phpcodesniffer

      Line exceeds 120 characters; contains 137 characters
      Open

                      $query = \sprintf('SELECT * FROM `%s` WHERE nleft >= %d AND nright <= %d ORDER BY nleft', $this->table, $nleft, $nright);
      Severity: Minor
      Found in class/NestedTree.php by phpcodesniffer

      The variable $parent_id is not named in camelCase.
      Open

          public function getDescendants($id = 0, $includeSelf = false, $childrenOnly = false)
          {
              $idField = $this->fields['id'];
      
              $node = $this->getNode($id);
      Severity: Minor
      Found in class/NestedTree.php by phpmd

      CamelCaseVariableName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name variables.

      Example

      class ClassName {
          public function doSomething() {
              $data_module = new DataModule();
          }
      }

      Source

      The variable $child_id is not named in camelCase.
      Open

          public function _generateTreeData(&$arr, $id, $level, &$n)
          {
              $arr[$id]['nlevel'] = $level;
              $arr[$id]['nleft']  = ++$n;
      
      
      Severity: Minor
      Found in class/NestedTree.php by phpmd

      CamelCaseVariableName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name variables.

      Example

      class ClassName {
          public function doSomething() {
              $data_module = new DataModule();
          }
      }

      Source

      The variable $ancestor_id is not named in camelCase.
      Open

          public function isDescendantOf($descendant_id, $ancestor_id)
          {
              $node = $this->getNode($ancestor_id);
              if (null === $node) {
                  return false;
      Severity: Minor
      Found in class/NestedTree.php by phpmd

      CamelCaseVariableName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name variables.

      Example

      class ClassName {
          public function doSomething() {
              $data_module = new DataModule();
          }
      }

      Source

      The variable $parent_id is not named in camelCase.
      Open

          public function isChildOf($child_id, $parent_id)
          {
              $query = \sprintf('SELECT COUNT(*) AS is_child FROM `%s` WHERE `%s` = %d AND %s = %d', $this->table, $this->fields['id'], $child_id, $this->fields['parent'], $parent_id);
      
              $result = $this->db->query($query);
      Severity: Minor
      Found in class/NestedTree.php by phpmd

      CamelCaseVariableName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name variables.

      Example

      class ClassName {
          public function doSomething() {
              $data_module = new DataModule();
          }
      }

      Source

      The variable $descendant_id is not named in camelCase.
      Open

          public function isDescendantOf($descendant_id, $ancestor_id)
          {
              $node = $this->getNode($ancestor_id);
              if (null === $node) {
                  return false;
      Severity: Minor
      Found in class/NestedTree.php by phpmd

      CamelCaseVariableName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name variables.

      Example

      class ClassName {
          public function doSomething() {
              $data_module = new DataModule();
          }
      }

      Source

      The variable $parent_id is not named in camelCase.
      Open

          public function getDescendants($id = 0, $includeSelf = false, $childrenOnly = false)
          {
              $idField = $this->fields['id'];
      
              $node = $this->getNode($id);
      Severity: Minor
      Found in class/NestedTree.php by phpmd

      CamelCaseVariableName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name variables.

      Example

      class ClassName {
          public function doSomething() {
              $data_module = new DataModule();
          }
      }

      Source

      The variable $parent_id is not named in camelCase.
      Open

          public function getDescendants($id = 0, $includeSelf = false, $childrenOnly = false)
          {
              $idField = $this->fields['id'];
      
              $node = $this->getNode($id);
      Severity: Minor
      Found in class/NestedTree.php by phpmd

      CamelCaseVariableName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name variables.

      Example

      class ClassName {
          public function doSomething() {
              $data_module = new DataModule();
          }
      }

      Source

      The variable $parent_id is not named in camelCase.
      Open

          public function getDescendants($id = 0, $includeSelf = false, $childrenOnly = false)
          {
              $idField = $this->fields['id'];
      
              $node = $this->getNode($id);
      Severity: Minor
      Found in class/NestedTree.php by phpmd

      CamelCaseVariableName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name variables.

      Example

      class ClassName {
          public function doSomething() {
              $data_module = new DataModule();
          }
      }

      Source

      The variable $child_id is not named in camelCase.
      Open

          public function _generateTreeData(&$arr, $id, $level, &$n)
          {
              $arr[$id]['nlevel'] = $level;
              $arr[$id]['nleft']  = ++$n;
      
      
      Severity: Minor
      Found in class/NestedTree.php by phpmd

      CamelCaseVariableName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name variables.

      Example

      class ClassName {
          public function doSomething() {
              $data_module = new DataModule();
          }
      }

      Source

      The variable $parent_id is not named in camelCase.
      Open

          public function getDescendants($id = 0, $includeSelf = false, $childrenOnly = false)
          {
              $idField = $this->fields['id'];
      
              $node = $this->getNode($id);
      Severity: Minor
      Found in class/NestedTree.php by phpmd

      CamelCaseVariableName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name variables.

      Example

      class ClassName {
          public function doSomething() {
              $data_module = new DataModule();
          }
      }

      Source

      The variable $child_id is not named in camelCase.
      Open

          public function isChildOf($child_id, $parent_id)
          {
              $query = \sprintf('SELECT COUNT(*) AS is_child FROM `%s` WHERE `%s` = %d AND %s = %d', $this->table, $this->fields['id'], $child_id, $this->fields['parent'], $parent_id);
      
              $result = $this->db->query($query);
      Severity: Minor
      Found in class/NestedTree.php by phpmd

      CamelCaseVariableName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name variables.

      Example

      class ClassName {
          public function doSomething() {
              $data_module = new DataModule();
          }
      }

      Source

      The method _generateTreeData is not named in camelCase.
      Open

          public function _generateTreeData(&$arr, $id, $level, &$n)
          {
              $arr[$id]['nlevel'] = $level;
              $arr[$id]['nleft']  = ++$n;
      
      
      Severity: Minor
      Found in class/NestedTree.php by phpmd

      CamelCaseMethodName

      Since: 0.2

      It is considered best practice to use the camelCase notation to name methods.

      Example

      class ClassName {
          public function get_name() {
          }
      }

      Source

      There are no issues that match your filters.

      Category
      Status