src/Expression.php

Summary

Maintainability
D
2 days
Test Coverage

File Expression.php has 393 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

declare(strict_types=1);

namespace Atk4\Dsql;
Severity: Minor
Found in src/Expression.php - About 5 hrs to fix

    Function execute has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
    Open

        public function execute(object $connection = null): object
        {
            if ($connection === null) {
                $connection = $this->connection;
            }
    Severity: Minor
    Found in src/Expression.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

    Expression has 25 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Expression implements Expressionable, \ArrayAccess
    {
        /** @const string "[]" in template, escape as parameter */
        protected const ESCAPE_PARAM = 'param';
        /** @const string "{}" in template, escape as identifier */
    Severity: Minor
    Found in src/Expression.php - About 2 hrs to fix

      Method execute has 56 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function execute(object $connection = null): object
          {
              if ($connection === null) {
                  $connection = $this->connection;
              }
      Severity: Major
      Found in src/Expression.php - About 2 hrs to fix

        Method render has 56 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function render(): string
            {
                $hadUnderscoreParamBase = $this->_paramBase !== null;
                if (!$hadUnderscoreParamBase) {
                    $hadUnderscoreParamBase = false;
        Severity: Major
        Found in src/Expression.php - About 2 hrs to fix

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

              public function getDebugQuery(): string
              {
                  $result = $this->render();
          
                  foreach (array_reverse($this->params) as $key => $val) {
          Severity: Minor
          Found in src/Expression.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 consume has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected function consume($expression, string $escapeMode = self::ESCAPE_PARAM)
              {
                  if (!is_object($expression)) {
                      switch ($escapeMode) {
                          case self::ESCAPE_PARAM:
          Severity: Minor
          Found in src/Expression.php - About 1 hr to fix

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

                public function __construct($properties = [], $arguments = null)
                {
                    // save template
                    if (is_string($properties)) {
                        $properties = ['template' => $properties];
            Severity: Minor
            Found in src/Expression.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 $ret;
            Severity: Major
            Found in src/Expression.php - About 30 mins to fix

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

                  protected function consume($expression, string $escapeMode = self::ESCAPE_PARAM)
                  {
                      if (!is_object($expression)) {
                          switch ($escapeMode) {
                              case self::ESCAPE_PARAM:
              Severity: Minor
              Found in src/Expression.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