iranianpep/code-jetter

View on GitHub
core/database/QueryMaker.php

Summary

Maintainability
F
4 days
Test Coverage

Function where has a Cognitive Complexity of 63 (exceeds 5 allowed). Consider refactoring.
Open

    private function where(array $criteria)
    {
        if (!empty($criteria)) {
            $where = ' WHERE ';

Severity: Minor
Found in core/database/QueryMaker.php - About 1 day 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

File QueryMaker.php has 380 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace CodeJetter\core\database;

use CodeJetter\core\utility\MysqlUtility;
Severity: Minor
Found in core/database/QueryMaker.php - About 5 hrs to fix

    Function bindCriteria has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

        private function bindCriteria(\PDOStatement $statement, array $criteria)
        {
            // bind criteria values
            if (!empty($criteria)) {
                $counter = 0;
    Severity: Minor
    Found in core/database/QueryMaker.php - About 4 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 batchBindValues has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        public function batchBindValues(
            \PDOStatement $statement,
            array $criteria,
            $start = 0,
            $limit = 0,
    Severity: Minor
    Found in core/database/QueryMaker.php - About 3 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

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

    class QueryMaker
    {
        private $tables;
        private $validComparisonOperators = ['LIKE', 'NOT LIKE', '=', '!=', '<>', '<', '<=', '>', '>=', '<=>', 'IS NOT',
            'IS', 'IS NOT NULL', 'IS NULL', 'IN', 'NOT IN', ];
    Severity: Minor
    Found in core/database/QueryMaker.php by phpmd

    Method where has 72 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function where(array $criteria)
        {
            if (!empty($criteria)) {
                $where = ' WHERE ';
    
    
    Severity: Major
    Found in core/database/QueryMaker.php - About 2 hrs to fix

      Function getSelectFromTables has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          public function getSelectFromTables($fromColumns = null)
          {
              $joinedSelect = [];
              $counter = 1;
              $from = '';
      Severity: Minor
      Found in core/database/QueryMaker.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

      QueryMaker has 21 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class QueryMaker
      {
          private $tables;
          private $validComparisonOperators = ['LIKE', 'NOT LIKE', '=', '!=', '<>', '<', '<=', '>', '>=', '<=>', 'IS NOT',
              'IS', 'IS NOT NULL', 'IS NULL', 'IN', 'NOT IN', ];
      Severity: Minor
      Found in core/database/QueryMaker.php - About 2 hrs to fix

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

            public function bindValues(\PDOStatement $statement, array $criteria, $start = 0, $limit = 0, array $fieldsValues = [])
            {
                // bind criteria values
                $this->bindCriteria($statement, $criteria);
        
        
        Severity: Minor
        Found in core/database/QueryMaker.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 getSelectFromTables has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getSelectFromTables($fromColumns = null)
            {
                $joinedSelect = [];
                $counter = 1;
                $from = '';
        Severity: Minor
        Found in core/database/QueryMaker.php - About 1 hr to fix

          Method bindCriteria has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private function bindCriteria(\PDOStatement $statement, array $criteria)
              {
                  // bind criteria values
                  if (!empty($criteria)) {
                      $counter = 0;
          Severity: Minor
          Found in core/database/QueryMaker.php - About 1 hr to fix

            Function batchInsertQuery has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
            Open

                public function batchInsertQuery(array $fieldsValuesCollection)
                {
                    if (empty($fieldsValuesCollection)) {
                        throw new \Exception('fieldsValues cannot be empty in insertQuery function');
                    }
            Severity: Minor
            Found in core/database/QueryMaker.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 batchBindValues has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    \PDOStatement $statement,
                    array $criteria,
                    $start = 0,
                    $limit = 0,
                    array $fieldsValuesCollection = []
            Severity: Minor
            Found in core/database/QueryMaker.php - About 35 mins to fix

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

                  public function selectQuery(array $criteria = [], $fromColumns = '*', $order = '', $start = 0, $limit = 0)
              Severity: Minor
              Found in core/database/QueryMaker.php - About 35 mins to fix

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

                    public function bindValues(\PDOStatement $statement, array $criteria, $start = 0, $limit = 0, array $fieldsValues = [])
                Severity: Minor
                Found in core/database/QueryMaker.php - About 35 mins to fix

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

                      public function insertQuery(array $fieldsValues)
                      {
                          if (empty($fieldsValues)) {
                              throw new \Exception('fieldsValues cannot be empty in insertQuery function');
                          }
                  Severity: Minor
                  Found in core/database/QueryMaker.php - About 35 mins to fix

                  Cognitive Complexity

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

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

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

                  Further reading

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

                      public function updateQuery(array $criteria, $fieldsValues, $start, $limit)
                      {
                          if (empty($fieldsValues)) {
                              throw new \Exception('fieldsValues cannot be empty in updateQuery function');
                          }
                  Severity: Minor
                  Found in core/database/QueryMaker.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 where() has an NPath complexity of 27220. The configured NPath complexity threshold is 200.
                  Open

                      private function where(array $criteria)
                      {
                          if (!empty($criteria)) {
                              $where = ' WHERE ';
                  
                  
                  Severity: Minor
                  Found in core/database/QueryMaker.php by phpmd

                  NPathComplexity

                  Since: 0.1

                  The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

                  Example

                  class Foo {
                      function bar() {
                          // lots of complicated code
                      }
                  }

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

                  The method where() has 102 lines of code. Current threshold is set to 100. Avoid really long methods.
                  Open

                      private function where(array $criteria)
                      {
                          if (!empty($criteria)) {
                              $where = ' WHERE ';
                  
                  
                  Severity: Minor
                  Found in core/database/QueryMaker.php by phpmd

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

                      private function where(array $criteria)
                      {
                          if (!empty($criteria)) {
                              $where = ' WHERE ';
                  
                  
                  Severity: Minor
                  Found in core/database/QueryMaker.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

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

                      public function getSelectFromTables($fromColumns = null)
                      {
                          $joinedSelect = [];
                          $counter = 1;
                          $from = '';
                  Severity: Minor
                  Found in core/database/QueryMaker.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

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

                      public function batchBindValues(
                          \PDOStatement $statement,
                          array $criteria,
                          $start = 0,
                          $limit = 0,
                  Severity: Minor
                  Found in core/database/QueryMaker.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

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

                      private function bindCriteria(\PDOStatement $statement, array $criteria)
                      {
                          // bind criteria values
                          if (!empty($criteria)) {
                              $counter = 0;
                  Severity: Minor
                  Found in core/database/QueryMaker.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

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

                              throw new \Exception('fieldsValues cannot be empty in insertQuery function');
                  Severity: Minor
                  Found in core/database/QueryMaker.php by phpmd

                  MissingImport

                  Since: 2.7.0

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

                  Example

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

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

                  Missing class import via use statement (line '300', column '35').
                  Open

                                          throw new \Exception("'{$aCriteria['logicalOperator']}' is not a valid logical operator");
                  Severity: Minor
                  Found in core/database/QueryMaker.php by phpmd

                  MissingImport

                  Since: 2.7.0

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

                  Example

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

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

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

                              throw new \Exception('fieldsValues cannot be empty in insertQuery function');
                  Severity: Minor
                  Found in core/database/QueryMaker.php by phpmd

                  MissingImport

                  Since: 2.7.0

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

                  Example

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

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

                  Missing class import via use statement (line '289', column '31').
                  Open

                                      throw new \Exception("'{$aCriteria['operator']}' is not a valid comparison operator");
                  Severity: Minor
                  Found in core/database/QueryMaker.php by phpmd

                  MissingImport

                  Since: 2.7.0

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

                  Example

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

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

                  Missing class import via use statement (line '280', column '31').
                  Open

                                      throw new \Exception('Column name cannot be empty');
                  Severity: Minor
                  Found in core/database/QueryMaker.php by phpmd

                  MissingImport

                  Since: 2.7.0

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

                  Example

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

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

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

                              throw new \Exception('fieldsValues cannot be empty in updateQuery function');
                  Severity: Minor
                  Found in core/database/QueryMaker.php by phpmd

                  MissingImport

                  Since: 2.7.0

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

                  Example

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

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

                  Missing class import via use statement (line '614', column '31').
                  Open

                                      throw new \Exception("join array must have 'on'");
                  Severity: Minor
                  Found in core/database/QueryMaker.php by phpmd

                  MissingImport

                  Since: 2.7.0

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

                  Example

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

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

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

                              throw new \Exception('Tables cannot be empty');
                  Severity: Minor
                  Found in core/database/QueryMaker.php by phpmd

                  MissingImport

                  Since: 2.7.0

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

                  Example

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

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

                  Missing class import via use statement (line '569', column '27').
                  Open

                                  throw new \Exception("Requested table does not exist for the alias: {$tableAlias}");
                  Severity: Minor
                  Found in core/database/QueryMaker.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 batchInsertQuery uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                  Open

                                  } else {
                                      $placeholder = $this->preparePlaceholder($fieldValue['column']);
                                      $parameters[] = ":{$placeholder}{$key}";
                                  }
                  Severity: Minor
                  Found in core/database/QueryMaker.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 updateQuery uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                  Open

                              } else {
                                  $placeholder = $this->preparePlaceholder($fieldValue['column']);
                                  $query .= "{$fieldValue['column']} = :{$placeholder}{$comma}";
                              }
                  Severity: Minor
                  Found in core/database/QueryMaker.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 __construct uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                  Open

                              } else {
                                  // $tables is string, treat it as a table
                                  $this->addTable(
                                      $tables,
                                      [
                  Severity: Minor
                  Found in core/database/QueryMaker.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 insertQuery uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                  Open

                              } else {
                                  $placeholder = $this->preparePlaceholder($fieldValue['column']);
                                  $parameters[] = ":{$placeholder}";
                              }
                  Severity: Minor
                  Found in core/database/QueryMaker.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 where uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                  Open

                                  } else {
                                      // counter is greater than 1 and $aCriteria['logicalOperator'] is NOT empty, validate it first
                                      if (!in_array($aCriteria['logicalOperator'], $this->validLogicalOperators)) {
                                          throw new \Exception("'{$aCriteria['logicalOperator']}' is not a valid logical operator");
                                      }
                  Severity: Minor
                  Found in core/database/QueryMaker.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 getTable uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                  Open

                          } else {
                              if (array_key_exists($tableAlias, $tables)) {
                                  return $tables[$tableAlias];
                              } else {
                                  throw new \Exception("Requested table does not exist for the alias: {$tableAlias}");
                  Severity: Minor
                  Found in core/database/QueryMaker.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 where uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                  Open

                          } else {
                              return '';
                          }
                  Severity: Minor
                  Found in core/database/QueryMaker.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 where uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                  Open

                                  } else {
                                      // append it to the key in $nested
                                      if (!isset($nested[$aCriteria['nested']['key']])) {
                                          $nested[$aCriteria['nested']['key']] = $toBeAppended;
                                      } else {
                  Severity: Minor
                  Found in core/database/QueryMaker.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 where uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                  Open

                                  } else {
                                      // IS NULL and IS NOT NULL do NOT need a parameter
                                      if ($aCriteria['operator'] !== 'IS NULL' && $aCriteria['operator'] !== 'IS NOT NULL') {
                                          $placeholder = $this->preparePlaceholder($aCriteria['column']);
                                          $toBeAppended .= ":{$placeholder}{$counter} ";
                  Severity: Minor
                  Found in core/database/QueryMaker.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 bindCriteria uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                  Open

                                      } else {
                                          // value is not array
                                          // to override the automatic detection $aCriteria['type'] needs to be passed
                                          $type = empty($aCriteria['type']) ? $this->detectParameterType($aCriteria['value']) : $aCriteria['type'];
                                          $statement->bindValue(':'.$placeholder.$counter, $aCriteria['value'], $type);
                  Severity: Minor
                  Found in core/database/QueryMaker.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 where uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                  Open

                                      } else {
                                          $nested[$aCriteria['nested']['key']] .= $toBeAppended;
                                      }
                  Severity: Minor
                  Found in core/database/QueryMaker.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 where uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                  Open

                                      } else {
                                          // value is not array
                                          $placeholder = $this->preparePlaceholder($aCriteria['column']);
                                          $toBeAppended .= "(:{$placeholder}{$counter}) ";
                                      }
                  Severity: Minor
                  Found in core/database/QueryMaker.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 bindCriteria uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                  Open

                                  } else {
                                      // set the type to string if it is empty
                                      if (empty($aCriteria['type'])) {
                                          $aCriteria['type'] = \PDO::PARAM_STR;
                                      }
                  Severity: Minor
                  Found in core/database/QueryMaker.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 getSelectFromTables uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                  Open

                              } else {
                                  $from .= " JOIN `{$table['name']}` AS `{$tableAlias}`";
                  
                                  if (empty($table['on']) || !is_array($table['on'])) {
                                      throw new \Exception("join array must have 'on'");
                  Severity: Minor
                  Found in core/database/QueryMaker.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 getTable uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                  Open

                              } else {
                                  throw new \Exception("Requested table does not exist for the alias: {$tableAlias}");
                              }
                  Severity: Minor
                  Found in core/database/QueryMaker.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 '$fieldValueKey'.
                  Open

                          foreach ($fieldsValues as $fieldValueKey => $fieldValue) {
                  Severity: Minor
                  Found in core/database/QueryMaker.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 '$fieldValueKey'.
                  Open

                              foreach ($fieldsValues as $fieldValueKey => $fieldValue) {
                  Severity: Minor
                  Found in core/database/QueryMaker.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 private methods such as 'groupBy'.
                  Open

                      private function groupBy($field)
                      {
                          if (!empty($field)) {
                              return " GROUP BY {$field}";
                          }
                  Severity: Minor
                  Found in core/database/QueryMaker.php by phpmd

                  UnusedPrivateMethod

                  Since: 0.2

                  Unused Private Method detects when a private method is declared but is unused.

                  Example

                  class Something
                  {
                      private function foo() {} // unused
                  }

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

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

                                          foreach ($aCriteria['value'] as $key => $value) {
                  Severity: Minor
                  Found in core/database/QueryMaker.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 excessively long variable names like $validComparisonOperators. Keep variable name length under 20.
                  Open

                      private $validComparisonOperators = ['LIKE', 'NOT LIKE', '=', '!=', '<>', '<', '<=', '>', '>=', '<=>', 'IS NOT',
                          'IS', 'IS NOT NULL', 'IS NULL', 'IN', 'NOT IN', ];
                  Severity: Minor
                  Found in core/database/QueryMaker.php by phpmd

                  LongVariable

                  Since: 0.2

                  Detects when a field, formal or local variable is declared with a long name.

                  Example

                  class Something {
                      protected $reallyLongIntName = -3; // VIOLATION - Field
                      public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                          $otherReallyLongName = -5; // VIOLATION - Local
                          for ($interestingIntIndex = 0; // VIOLATION - For
                               $interestingIntIndex < 10;
                               $interestingIntIndex++ ) {
                          }
                      }
                  }

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

                  Avoid excessively long variable names like $fieldsValuesCollection. Keep variable name length under 20.
                  Open

                      public function batchInsertQuery(array $fieldsValuesCollection)
                  Severity: Minor
                  Found in core/database/QueryMaker.php by phpmd

                  LongVariable

                  Since: 0.2

                  Detects when a field, formal or local variable is declared with a long name.

                  Example

                  class Something {
                      protected $reallyLongIntName = -3; // VIOLATION - Field
                      public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                          $otherReallyLongName = -5; // VIOLATION - Local
                          for ($interestingIntIndex = 0; // VIOLATION - For
                               $interestingIntIndex < 10;
                               $interestingIntIndex++ ) {
                          }
                      }
                  }

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

                  Avoid excessively long variable names like $validLogicalOperators. Keep variable name length under 20.
                  Open

                      private $validLogicalOperators = ['AND', 'OR', 'XOR', 'NOT'];
                  Severity: Minor
                  Found in core/database/QueryMaker.php by phpmd

                  LongVariable

                  Since: 0.2

                  Detects when a field, formal or local variable is declared with a long name.

                  Example

                  class Something {
                      protected $reallyLongIntName = -3; // VIOLATION - Field
                      public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                          $otherReallyLongName = -5; // VIOLATION - Local
                          for ($interestingIntIndex = 0; // VIOLATION - For
                               $interestingIntIndex < 10;
                               $interestingIntIndex++ ) {
                          }
                      }
                  }

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

                  Avoid excessively long variable names like $fieldsValuesCollection. Keep variable name length under 20.
                  Open

                          array $fieldsValuesCollection = []
                  Severity: Minor
                  Found in core/database/QueryMaker.php by phpmd

                  LongVariable

                  Since: 0.2

                  Detects when a field, formal or local variable is declared with a long name.

                  Example

                  class Something {
                      protected $reallyLongIntName = -3; // VIOLATION - Field
                      public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                          $otherReallyLongName = -5; // VIOLATION - Local
                          for ($interestingIntIndex = 0; // VIOLATION - For
                               $interestingIntIndex < 10;
                               $interestingIntIndex++ ) {
                          }
                      }
                  }

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

                  Line exceeds 120 characters; contains 123 characters
                  Open

                      public function bindValues(\PDOStatement $statement, array $criteria, $start = 0, $limit = 0, array $fieldsValues = [])
                  Severity: Minor
                  Found in core/database/QueryMaker.php by phpcodesniffer

                  Line exceeds 120 characters; contains 129 characters
                  Open

                                          $type = empty($aCriteria['type']) ? $this->detectParameterType($aCriteria['value']) : $aCriteria['type'];
                  Severity: Minor
                  Found in core/database/QueryMaker.php by phpcodesniffer

                  The variable $LastFieldKey is not named in camelCase.
                  Open

                      public function updateQuery(array $criteria, $fieldsValues, $start, $limit)
                      {
                          if (empty($fieldsValues)) {
                              throw new \Exception('fieldsValues cannot be empty in updateQuery function');
                          }
                  Severity: Minor
                  Found in core/database/QueryMaker.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 $LastFieldKey is not named in camelCase.
                  Open

                      public function updateQuery(array $criteria, $fieldsValues, $start, $limit)
                      {
                          if (empty($fieldsValues)) {
                              throw new \Exception('fieldsValues cannot be empty in updateQuery function');
                          }
                  Severity: Minor
                  Found in core/database/QueryMaker.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

                  There are no issues that match your filters.

                  Category
                  Status