hnhdigital-os/laravel-model-filter

View on GitHub
src/Traits/ModelTrait.php

Summary

Maintainability
F
1 wk
Test Coverage

Function processAttributeFilter has a Cognitive Complexity of 70 (exceeds 5 allowed). Consider refactoring.
Open

    private static function processAttributeFilter($query, $filter_setting, $filter_requests)
    {
        $model = (new static());
        foreach ($filter_requests as $filter_request) {
            // Clean inputs
Severity: Minor
Found in src/Traits/ModelTrait.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

Function getFilterAttributes has a Cognitive Complexity of 58 (exceeds 5 allowed). Consider refactoring.
Open

    public static function getFilterAttributes($first_call = true)
    {
        $model = (new static());

        if (isset($model->filter_attributes) && is_array($model->filter_attributes)) {
Severity: Minor
Found in src/Traits/ModelTrait.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 ModelTrait.php has 518 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace HnhDigital\LaravelModelFilter\Traits;

use DB;
Severity: Major
Found in src/Traits/ModelTrait.php - About 1 day to fix

    Function getAppliedFiltersArray has a Cognitive Complexity of 37 (exceeds 5 allowed). Consider refactoring.
    Open

        public function getAppliedFiltersArray($search_request)
        {
            $model = (new static());
            $result = [];
            foreach ($model->getFilterAttributes() as $filter_name => $filter_settings) {
    Severity: Minor
    Found in src/Traits/ModelTrait.php - About 5 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 validateOperators has 135 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private static function validateOperators($filter, &$method, &$arguments, $model, $filter_setting, $operator, $value1, $value2)
        {
            // No space search.
            if (array_has($filter_setting, 'phone_search')) {
                $value1_numeric = str_replace(' ', '', $value1);
    Severity: Major
    Found in src/Traits/ModelTrait.php - About 5 hrs to fix

      Function validateOperators has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

          private static function validateOperators($filter, &$method, &$arguments, $model, $filter_setting, $operator, $value1, $value2)
          {
              // No space search.
              if (array_has($filter_setting, 'phone_search')) {
                  $value1_numeric = str_replace(' ', '', $value1);
      Severity: Minor
      Found in src/Traits/ModelTrait.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 scopeApplyAttributeFilters has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
      Open

          public function scopeApplyAttributeFilters($query, $search_request)
          {
              if (isset($search_request['filters']) && is_array($search_request['filters']) && !empty($search_request['filters'])) {
      
                  // Get available filters
      Severity: Minor
      Found in src/Traits/ModelTrait.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 processAttributeFilter has 77 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private static function processAttributeFilter($query, $filter_setting, $filter_requests)
          {
              $model = (new static());
              foreach ($filter_requests as $filter_request) {
                  // Clean inputs
      Severity: Major
      Found in src/Traits/ModelTrait.php - About 3 hrs to fix

        Method getFilterAttributes has 54 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function getFilterAttributes($first_call = true)
            {
                $model = (new static());
        
                if (isset($model->filter_attributes) && is_array($model->filter_attributes)) {
        Severity: Major
        Found in src/Traits/ModelTrait.php - About 2 hrs to fix

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

              public function scopeModelJoin($query, $relationships, $operator = '=', $type = 'left', $where = false)
              {
                  if (!is_array($relationships)) {
                      $relationships = [$relationships];
                  }
          Severity: Minor
          Found in src/Traits/ModelTrait.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 scopeModelJoin has 46 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function scopeModelJoin($query, $relationships, $operator = '=', $type = 'left', $where = false)
              {
                  if (!is_array($relationships)) {
                      $relationships = [$relationships];
                  }
          Severity: Minor
          Found in src/Traits/ModelTrait.php - About 1 hr to fix

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

                public function scopeApplyAttributeFilters($query, $search_request)
                {
                    if (isset($search_request['filters']) && is_array($search_request['filters']) && !empty($search_request['filters'])) {
            
                        // Get available filters
            Severity: Minor
            Found in src/Traits/ModelTrait.php - About 1 hr to fix

              Method getAppliedFiltersArray has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function getAppliedFiltersArray($search_request)
                  {
                      $model = (new static());
                      $result = [];
                      foreach ($model->getFilterAttributes() as $filter_name => $filter_settings) {
              Severity: Minor
              Found in src/Traits/ModelTrait.php - About 1 hr to fix

                Method validateOperators has 8 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    private static function validateOperators($filter, &$method, &$arguments, $model, $filter_setting, $operator, $value1, $value2)
                Severity: Major
                Found in src/Traits/ModelTrait.php - About 1 hr to fix

                  Avoid deeply nested control flow statements.
                  Open

                                                  if (isset($settings['name'])) {
                                                      $filter_detail['name'] = $settings['name'].': '.$filter_detail['attribute_name'];
                                                  }
                  Severity: Major
                  Found in src/Traits/ModelTrait.php - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                                if (in_array($check_operator, $available_operators)) {
                                                    $operator = $check_operator;
                                                    $value1 = implode(' ', $value1_array);
                                                }
                    Severity: Major
                    Found in src/Traits/ModelTrait.php - About 45 mins to fix

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

                          public function scopeModelJoin($query, $relationships, $operator = '=', $type = 'left', $where = false)
                      Severity: Minor
                      Found in src/Traits/ModelTrait.php - About 35 mins to fix

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

                            private static function applyFilterAttributeArray($query, $attribute_list, $method, $arguments, $positive = true)
                        Severity: Minor
                        Found in src/Traits/ModelTrait.php - About 35 mins to fix

                          Avoid too many return statements within this method.
                          Open

                                                  return true;
                          Severity: Major
                          Found in src/Traits/ModelTrait.php - About 30 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                                    return true;
                            Severity: Major
                            Found in src/Traits/ModelTrait.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                                      return true;
                              Severity: Major
                              Found in src/Traits/ModelTrait.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                                        return true;
                                Severity: Major
                                Found in src/Traits/ModelTrait.php - About 30 mins to fix

                                  Avoid too many return statements within this method.
                                  Open

                                                          return true;
                                  Severity: Major
                                  Found in src/Traits/ModelTrait.php - About 30 mins to fix

                                    Avoid too many return statements within this method.
                                    Open

                                                            return true;
                                    Severity: Major
                                    Found in src/Traits/ModelTrait.php - About 30 mins to fix

                                      Avoid too many return statements within this method.
                                      Open

                                                              return true;
                                      Severity: Major
                                      Found in src/Traits/ModelTrait.php - About 30 mins to fix

                                        Avoid too many return statements within this method.
                                        Open

                                                                return true;
                                        Severity: Major
                                        Found in src/Traits/ModelTrait.php - About 30 mins to fix

                                          Avoid too many return statements within this method.
                                          Open

                                                                  return true;
                                          Severity: Major
                                          Found in src/Traits/ModelTrait.php - About 30 mins to fix

                                            Avoid too many return statements within this method.
                                            Open

                                                                    return true;
                                            Severity: Major
                                            Found in src/Traits/ModelTrait.php - About 30 mins to fix

                                              Avoid too many return statements within this method.
                                              Open

                                                                      return true;
                                              Severity: Major
                                              Found in src/Traits/ModelTrait.php - About 30 mins to fix

                                                Avoid too many return statements within this method.
                                                Open

                                                                        return true;
                                                Severity: Major
                                                Found in src/Traits/ModelTrait.php - About 30 mins to fix

                                                  Avoid too many return statements within this method.
                                                  Open

                                                                          return true;
                                                  Severity: Major
                                                  Found in src/Traits/ModelTrait.php - About 30 mins to fix

                                                    Avoid too many return statements within this method.
                                                    Open

                                                                            return true;
                                                    Severity: Major
                                                    Found in src/Traits/ModelTrait.php - About 30 mins to fix

                                                      Avoid too many return statements within this method.
                                                      Open

                                                                              return true;
                                                      Severity: Major
                                                      Found in src/Traits/ModelTrait.php - About 30 mins to fix

                                                        Avoid too many return statements within this method.
                                                        Open

                                                                return false;
                                                        Severity: Major
                                                        Found in src/Traits/ModelTrait.php - About 30 mins to fix

                                                          Avoid too many return statements within this method.
                                                          Open

                                                                                  return true;
                                                          Severity: Major
                                                          Found in src/Traits/ModelTrait.php - About 30 mins to fix

                                                            Avoid too many return statements within this method.
                                                            Open

                                                                                    return true;
                                                            Severity: Major
                                                            Found in src/Traits/ModelTrait.php - About 30 mins to fix

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

                                                                  private static function validateOperators($filter, &$method, &$arguments, $model, $filter_setting, $operator, $value1, $value2)
                                                                  {
                                                                      // No space search.
                                                                      if (array_has($filter_setting, 'phone_search')) {
                                                                          $value1_numeric = str_replace(' ', '', $value1);
                                                              Severity: Minor
                                                              Found in src/Traits/ModelTrait.php by phpmd

                                                              The method validateOperators() has an NPath complexity of 234. The configured NPath complexity threshold is 200.
                                                              Open

                                                                  private static function validateOperators($filter, &$method, &$arguments, $model, $filter_setting, $operator, $value1, $value2)
                                                                  {
                                                                      // No space search.
                                                                      if (array_has($filter_setting, 'phone_search')) {
                                                                          $value1_numeric = str_replace(' ', '', $value1);
                                                              Severity: Minor
                                                              Found in src/Traits/ModelTrait.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 processAttributeFilter() has an NPath complexity of 7682. The configured NPath complexity threshold is 200.
                                                              Open

                                                                  private static function processAttributeFilter($query, $filter_setting, $filter_requests)
                                                                  {
                                                                      $model = (new static());
                                                                      foreach ($filter_requests as $filter_request) {
                                                                          // Clean inputs
                                                              Severity: Minor
                                                              Found in src/Traits/ModelTrait.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 scopeModelJoin() has a Cyclomatic Complexity of 12. The configured cyclomatic complexity threshold is 10.
                                                              Open

                                                                  public function scopeModelJoin($query, $relationships, $operator = '=', $type = 'left', $where = false)
                                                                  {
                                                                      if (!is_array($relationships)) {
                                                                          $relationships = [$relationships];
                                                                      }
                                                              Severity: Minor
                                                              Found in src/Traits/ModelTrait.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 getFilterAttributes() has a Cyclomatic Complexity of 19. The configured cyclomatic complexity threshold is 10.
                                                              Open

                                                                  public static function getFilterAttributes($first_call = true)
                                                                  {
                                                                      $model = (new static());
                                                              
                                                                      if (isset($model->filter_attributes) && is_array($model->filter_attributes)) {
                                                              Severity: Minor
                                                              Found in src/Traits/ModelTrait.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 getAppliedFiltersArray() has a Cyclomatic Complexity of 13. The configured cyclomatic complexity threshold is 10.
                                                              Open

                                                                  public function getAppliedFiltersArray($search_request)
                                                                  {
                                                                      $model = (new static());
                                                                      $result = [];
                                                                      foreach ($model->getFilterAttributes() as $filter_name => $filter_settings) {
                                                              Severity: Minor
                                                              Found in src/Traits/ModelTrait.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 processAttributeFilter() has a Cyclomatic Complexity of 30. The configured cyclomatic complexity threshold is 10.
                                                              Open

                                                                  private static function processAttributeFilter($query, $filter_setting, $filter_requests)
                                                                  {
                                                                      $model = (new static());
                                                                      foreach ($filter_requests as $filter_request) {
                                                                          // Clean inputs
                                                              Severity: Minor
                                                              Found in src/Traits/ModelTrait.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 validateOperators() has a Cyclomatic Complexity of 48. The configured cyclomatic complexity threshold is 10.
                                                              Open

                                                                  private static function validateOperators($filter, &$method, &$arguments, $model, $filter_setting, $operator, $value1, $value2)
                                                                  {
                                                                      // No space search.
                                                                      if (array_has($filter_setting, 'phone_search')) {
                                                                          $value1_numeric = str_replace(' ', '', $value1);
                                                              Severity: Minor
                                                              Found in src/Traits/ModelTrait.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 scopeApplyAttributeFilters() has a Cyclomatic Complexity of 16. The configured cyclomatic complexity threshold is 10.
                                                              Open

                                                                  public function scopeApplyAttributeFilters($query, $search_request)
                                                                  {
                                                                      if (isset($search_request['filters']) && is_array($search_request['filters']) && !empty($search_request['filters'])) {
                                                              
                                                                          // Get available filters
                                                              Severity: Minor
                                                              Found in src/Traits/ModelTrait.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 getFilterAttributes has a boolean flag argument $first_call, which is a certain sign of a Single Responsibility Principle violation.
                                                              Open

                                                                  public static function getFilterAttributes($first_call = true)
                                                              Severity: Minor
                                                              Found in src/Traits/ModelTrait.php by phpmd

                                                              BooleanArgumentFlag

                                                              Since: 1.4.0

                                                              A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

                                                              Example

                                                              class Foo {
                                                                  public function bar($flag = true) {
                                                                  }
                                                              }

                                                              Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

                                                              The method applyFilterAttributeArray has a boolean flag argument $positive, which is a certain sign of a Single Responsibility Principle violation.
                                                              Open

                                                                  private static function applyFilterAttributeArray($query, $attribute_list, $method, $arguments, $positive = true)
                                                              Severity: Minor
                                                              Found in src/Traits/ModelTrait.php by phpmd

                                                              BooleanArgumentFlag

                                                              Since: 1.4.0

                                                              A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

                                                              Example

                                                              class Foo {
                                                                  public function bar($flag = true) {
                                                                  }
                                                              }

                                                              Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

                                                              The method getFilterOperators has a boolean flag argument $operator, which is a certain sign of a Single Responsibility Principle violation.
                                                              Open

                                                                  public function getFilterOperators($type, $operator = false)
                                                              Severity: Minor
                                                              Found in src/Traits/ModelTrait.php by phpmd

                                                              BooleanArgumentFlag

                                                              Since: 1.4.0

                                                              A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

                                                              Example

                                                              class Foo {
                                                                  public function bar($flag = true) {
                                                                  }
                                                              }

                                                              Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

                                                              The method scopeModelJoin has a boolean flag argument $where, which is a certain sign of a Single Responsibility Principle violation.
                                                              Open

                                                                  public function scopeModelJoin($query, $relationships, $operator = '=', $type = 'left', $where = false)
                                                              Severity: Minor
                                                              Found in src/Traits/ModelTrait.php by phpmd

                                                              BooleanArgumentFlag

                                                              Since: 1.4.0

                                                              A boolean flag argument is a reliable indicator for a violation of the Single Responsibility Principle (SRP). You can fix this problem by extracting the logic in the boolean flag into its own class or method.

                                                              Example

                                                              class Foo {
                                                                  public function bar($flag = true) {
                                                                  }
                                                              }

                                                              Source https://phpmd.org/rules/cleancode.html#booleanargumentflag

                                                              The method processAttributeFilter uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                                              Open

                                                                                  } else {
                                                                                      if (is_array($arguments)) {
                                                                                          if (($method === 'whereIn' || $method === 'whereNotIn')
                                                                                              && empty($arguments[0])) {
                                                                                              break;
                                                              Severity: Minor
                                                              Found in src/Traits/ModelTrait.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 processAttributeFilter uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                                              Open

                                                                                      } else {
                                                                                          $query = $query->$method($attribute.$arguments);
                                                                                      }
                                                              Severity: Minor
                                                              Found in src/Traits/ModelTrait.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 validateOperators uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                                              Open

                                                                                  } else {
                                                                                      $value1 = [];
                                                                                  }
                                                              Severity: Minor
                                                              Found in src/Traits/ModelTrait.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 applyFilterAttributeArray uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                                              Open

                                                                          } else {
                                                                              $method_argument = [$attribute.$method_argument];
                                                                          }
                                                              Severity: Minor
                                                              Found in src/Traits/ModelTrait.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 getFilterAttributes uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                                              Open

                                                                              } else {
                                                                                  unset($filters[$key]);
                                                                              }
                                                              Severity: Minor
                                                              Found in src/Traits/ModelTrait.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 scopeModelJoin uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                                              Open

                                                                          } else {
                                                                              $table = $relation->getTable();
                                                                          }
                                                              Severity: Minor
                                                              Found in src/Traits/ModelTrait.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 getFilterAttributes uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                                              Open

                                                                                  } else {
                                                                                      if ($filter_detail['attribute'][0] === '{') {
                                                                                          $filter_detail['attribute'] = new Expression(substr($filter_detail['attribute'], 1));
                                                                                      } elseif (strpos($filter_detail['attribute'], '.') === false) {
                                                                                          $filter_detail['attribute'] = $model->getTable().'.'.$filter_detail['attribute'];
                                                              Severity: Minor
                                                              Found in src/Traits/ModelTrait.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 validateOperators uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
                                                              Open

                                                                              } else {
                                                                                  $value1 = [];
                                                                              }
                                                              Severity: Minor
                                                              Found in src/Traits/ModelTrait.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 '$model_class'.
                                                              Open

                                                                              foreach ($relationships as $method_name => $model_class) {
                                                              Severity: Minor
                                                              Found in src/Traits/ModelTrait.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 '$filter_list'.
                                                              Open

                                                                                      $filter_list = '';
                                                              Severity: Minor
                                                              Found in src/Traits/ModelTrait.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 parameters such as '$value2'.
                                                              Open

                                                                  private static function validateOperators($filter, &$method, &$arguments, $model, $filter_setting, $operator, $value1, $value2)
                                                              Severity: Minor
                                                              Found in src/Traits/ModelTrait.php by phpmd

                                                              UnusedFormalParameter

                                                              Since: 0.2

                                                              Avoid passing parameters to methods or constructors and then not using those parameters.

                                                              Example

                                                              class Foo
                                                              {
                                                                  private function bar($howdy)
                                                                  {
                                                                      // $howdy is not used
                                                                  }
                                                              }

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

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

                                                                                  $available_attributes = array_keys($model->attribute_rules);
                                                              Severity: Minor
                                                              Found in src/Traits/ModelTrait.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 '$query_connections'.
                                                              Open

                                                                              $query_connections = [];
                                                              Severity: Minor
                                                              Found in src/Traits/ModelTrait.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 $related_qualified_key_name. Keep variable name length under 20.
                                                              Open

                                                                              $related_qualified_key_name = $related_relation->getQualifiedKeyName();
                                                              Severity: Minor
                                                              Found in src/Traits/ModelTrait.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 $total_relationship_models. Keep variable name length under 20.
                                                              Open

                                                                          $total_relationship_models = 0;
                                                              Severity: Minor
                                                              Found in src/Traits/ModelTrait.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

                                                              There are no issues that match your filters.

                                                              Category
                                                              Status