squirrelphp/queries

View on GitHub
src/Doctrine/DBConvertStructuredQueryToSQL.php

Summary

Maintainability
F
5 days
Test Coverage
A
100%

File DBConvertStructuredQueryToSQL.php has 405 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace Squirrel\Queries\Doctrine;

use Squirrel\Debug\Debug;
Severity: Minor
Found in src/Doctrine/DBConvertStructuredQueryToSQL.php - About 5 hrs to fix

    Consider simplifying this complex logical expression.
    Open

                if (
                    \str_contains($expression, ' ')
                    || \str_contains($expression, '=')
                    || \str_contains($expression, '<')
                    || \str_contains($expression, '>')
    Severity: Critical
    Found in src/Doctrine/DBConvertStructuredQueryToSQL.php - About 3 hrs to fix

      Function buildChanges has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

          public function buildChanges(array $changes, array $queryValues): array
          {
              // List of finished change expressions, to be imploded with ,
              $changesList = [];
      
      
      Severity: Minor
      Found in src/Doctrine/DBConvertStructuredQueryToSQL.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

      Method verifyAndProcessOptions has 89 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function verifyAndProcessOptions(array $validOptions, array $options): array
          {
              // Convert "table" to "tables"
              if (
                  isset($options['table'])
      Severity: Major
      Found in src/Doctrine/DBConvertStructuredQueryToSQL.php - About 3 hrs to fix

        Function verifyAndProcessOptions has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
        Open

            public function verifyAndProcessOptions(array $validOptions, array $options): array
            {
                // Convert "table" to "tables"
                if (
                    isset($options['table'])
        Severity: Minor
        Found in src/Doctrine/DBConvertStructuredQueryToSQL.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

        Function buildWhere has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
        Open

            public function buildWhere(array $whereOptions, array $queryValues = []): array
            {
                // If no WHERE restrictions are defined, we just do "WHERE 1"
                if (\count($whereOptions) === 0) {
                    return ['1', $queryValues];
        Severity: Minor
        Found in src/Doctrine/DBConvertStructuredQueryToSQL.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

        Function buildFieldSelection has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            public function buildFieldSelection(array $fields): string
            {
                // No fields mean we select all fields!
                if (\count($fields) === 0) {
                    return '*';
        Severity: Minor
        Found in src/Doctrine/DBConvertStructuredQueryToSQL.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 buildChanges has 54 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function buildChanges(array $changes, array $queryValues): array
            {
                // List of finished change expressions, to be imploded with ,
                $changesList = [];
        
        
        Severity: Major
        Found in src/Doctrine/DBConvertStructuredQueryToSQL.php - About 2 hrs to fix

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

              public function buildOrderBy(array $orderOptions): string
              {
                  // List of finished WHERE expressions, to be imploded with ANDs
                  $orderProcessed = [];
          
          
          Severity: Minor
          Found in src/Doctrine/DBConvertStructuredQueryToSQL.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 buildWhere has 52 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function buildWhere(array $whereOptions, array $queryValues = []): array
              {
                  // If no WHERE restrictions are defined, we just do "WHERE 1"
                  if (\count($whereOptions) === 0) {
                      return ['1', $queryValues];
          Severity: Major
          Found in src/Doctrine/DBConvertStructuredQueryToSQL.php - About 2 hrs to fix

            Method buildFieldSelection has 45 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function buildFieldSelection(array $fields): string
                {
                    // No fields mean we select all fields!
                    if (\count($fields) === 0) {
                        return '*';
            Severity: Minor
            Found in src/Doctrine/DBConvertStructuredQueryToSQL.php - About 1 hr to fix

              Method buildGroupBy has 40 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function buildGroupBy(array $groupByOptions): string
                  {
                      // List of finished WHERE expressions, to be imploded with ANDs
                      $groupByProcessed = [];
              
              
              Severity: Minor
              Found in src/Doctrine/DBConvertStructuredQueryToSQL.php - About 1 hr to fix

                Method buildOrderBy has 38 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public function buildOrderBy(array $orderOptions): string
                    {
                        // List of finished WHERE expressions, to be imploded with ANDs
                        $orderProcessed = [];
                
                
                Severity: Minor
                Found in src/Doctrine/DBConvertStructuredQueryToSQL.php - About 1 hr to fix

                  Function buildGroupBy has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function buildGroupBy(array $groupByOptions): string
                      {
                          // List of finished WHERE expressions, to be imploded with ANDs
                          $groupByProcessed = [];
                  
                  
                  Severity: Minor
                  Found in src/Doctrine/DBConvertStructuredQueryToSQL.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

                  Function buildTableJoins has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function buildTableJoins(array $tables): array
                      {
                          // List of query values for PDO
                          $queryValues = [];
                  
                  
                  Severity: Minor
                  Found in src/Doctrine/DBConvertStructuredQueryToSQL.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 buildTableJoins has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function buildTableJoins(array $tables): array
                      {
                          // List of query values for PDO
                          $queryValues = [];
                  
                  
                  Severity: Minor
                  Found in src/Doctrine/DBConvertStructuredQueryToSQL.php - About 1 hr to fix

                    Consider simplifying this complex logical expression.
                    Open

                                if (
                                    \str_contains($expression, ' ')
                                    || \str_contains($expression, '=')
                                    || \str_contains($expression, '<')
                                    || \str_contains($expression, '>')
                    Severity: Major
                    Found in src/Doctrine/DBConvertStructuredQueryToSQL.php - About 40 mins to fix

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

                          private function addQueryVariablesNoNull(array $existingValues, mixed $newValues): array
                          {
                              // Convert to array of values if not already done
                              if (!\is_array($newValues)) {
                                  $newValues = [$newValues];
                      Severity: Minor
                      Found in src/Doctrine/DBConvertStructuredQueryToSQL.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

                      There are no issues that match your filters.

                      Category
                      Status