fpdo/fluentpdo

View on GitHub
src/Queries/Base.php

Summary

Maintainability
D
2 days
Test Coverage

File Base.php has 322 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace Envms\FluentPDO\Queries;

use DateTime, IteratorAggregate, PDO, PDOStatement;
Severity: Minor
Found in src/Queries/Base.php - About 3 hrs to fix

    Base has 29 functions (exceeds 20 allowed). Consider refactoring.
    Open

    abstract class Base implements IteratorAggregate
    {
    
        /** @var float */
        private $totalTime;
    Severity: Minor
    Found in src/Queries/Base.php - About 3 hrs to fix

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

          private function debug()
          {
              if (!empty($this->fluent->debug)) {
                  if (!is_callable($this->fluent->debug)) {
                      $backtrace = '';
      Severity: Minor
      Found in src/Queries/Base.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 convertNullValues has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function convertNullValues(): void
          {
              $filterList = ['VALUES', 'ON DUPLICATE KEY UPDATE', 'SET'];
      
              foreach ($this->statements as $clause => $statement) {
      Severity: Minor
      Found in src/Queries/Base.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 buildParameters has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          protected function buildParameters(): array
          {
              $parameters = [];
              foreach ($this->parameters as $clauses) {
                  if ($this->fluent->convertWrite === true) {
      Severity: Minor
      Found in src/Queries/Base.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 debug has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function debug()
          {
              if (!empty($this->fluent->debug)) {
                  if (!is_callable($this->fluent->debug)) {
                      $backtrace = '';
      Severity: Minor
      Found in src/Queries/Base.php - About 1 hr to fix

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

            protected function buildQuery()
            {
                if ($this->fluent->convertWrite === true) {
                    $this->convertNullValues();
                }
        Severity: Minor
        Found in src/Queries/Base.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 quote has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            protected function quote($value)
            {
                if (!isset($value)) {
                    return "NULL";
                }
        Severity: Minor
        Found in src/Queries/Base.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 0;
        Severity: Major
        Found in src/Queries/Base.php - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                      return (string)$value;
          Severity: Major
          Found in src/Queries/Base.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                    return $this->fluent->getPdo()->quote($value);
            Severity: Major
            Found in src/Queries/Base.php - About 30 mins to fix

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

                  protected function addStatement($clause, $statement, $parameters = [])
                  {
                      if ($statement === null) {
                          return $this->resetClause($clause);
                      }
              Severity: Minor
              Found in src/Queries/Base.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