fpdo/fluentpdo

View on GitHub
src/Queries/Common.php

Summary

Maintainability
D
1 day
Test Coverage

File Common.php has 284 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace Envms\FluentPDO\Queries;

use Envms\FluentPDO\{Exception, Literal, Utilities};
Severity: Minor
Found in src/Queries/Common.php - About 2 hrs to fix

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

        public function where($condition, $parameters = [], $separator = 'AND')
        {
            if ($condition === null) {
                return $this->resetClause('WHERE');
            }
    Severity: Minor
    Found in src/Queries/Common.php - About 2 hrs to fix

    Cognitive Complexity

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

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

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

    Further reading

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

        private function createUndefinedJoins($statement)
        {
            if ($this->isEscapedJoin($statement)) {
                return $statement;
            }
    Severity: Minor
    Found in src/Queries/Common.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 where has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function where($condition, $parameters = [], $separator = 'AND')
        {
            if ($condition === null) {
                return $this->resetClause('WHERE');
            }
    Severity: Minor
    Found in src/Queries/Common.php - About 1 hr to fix

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

          private function createUndefinedJoins($statement)
          {
              if ($this->isEscapedJoin($statement)) {
                  return $statement;
              }
      Severity: Minor
      Found in src/Queries/Common.php - About 1 hr to fix

        Function addJoinStatements has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

            private function addJoinStatements($clause, $statement, $parameters = [])
            {
                if ($statement === null) {
                    $this->joins = [];
        
        
        Severity: Minor
        Found in src/Queries/Common.php - About 55 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

        Method applyTableJoin has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            private function applyTableJoin($clause, $parameters, $mainTable, $joinItem, $lastItem, $joinAlias)
        Severity: Minor
        Found in src/Queries/Common.php - About 45 mins to fix

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

              private function addRawJoins($clause, $statement, $parameters, $joinAlias, $joinTable)
          Severity: Minor
          Found in src/Queries/Common.php - About 35 mins to fix

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

                private function createJoinStatement($clause, $mainTable, $joinTable, $joinAlias = '')
                {
                    if (in_array(substr($mainTable, -1), [':', '.'])) {
                        $mainTable = substr($mainTable, 0, -1);
                    }
            Severity: Minor
            Found in src/Queries/Common.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

            Avoid too many return statements within this method.
            Open

                            return $this->addWhereStatement($condition, $separator);
            Severity: Major
            Found in src/Queries/Common.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                              return $this->addWhereStatement('FALSE', $separator);
              Severity: Major
              Found in src/Queries/Common.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                return $this->addWhereStatement("$condition IN $in", $separator);
                Severity: Major
                Found in src/Queries/Common.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                          return $this->addWhereStatement($condition, $separator, $args);
                  Severity: Major
                  Found in src/Queries/Common.php - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                    return $this->addWhereStatement("$condition IS NULL", $separator);
                    Severity: Major
                    Found in src/Queries/Common.php - About 30 mins to fix

                      There are no issues that match your filters.

                      Category
                      Status