bnomei/kirby-mongodb

View on GitHub
classes/ModelWithKhulan.php

Summary

Maintainability
F
3 days
Test Coverage
B
80%

Function encodeKhulan has a Cognitive Complexity of 73 (exceeds 5 allowed). Consider refactoring.
Open

    public function encodeKhulan(?array $data = null, ?string $languageCode = null): array
    {
        if (! $data) {
            return [];
        }
Severity: Minor
Found in classes/ModelWithKhulan.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

Method encodeKhulan has 97 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function encodeKhulan(?array $data = null, ?string $languageCode = null): array
    {
        if (! $data) {
            return [];
        }
Severity: Major
Found in classes/ModelWithKhulan.php - About 3 hrs to fix

    File ModelWithKhulan.php has 305 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    declare(strict_types=1);
    
    namespace Bnomei;
    Severity: Minor
    Found in classes/ModelWithKhulan.php - About 3 hrs to fix

      Method writeKhulan has 60 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function writeKhulan(?array $data = null, ?string $languageCode = null): bool
          {
              if (option('bnomei.mongodb.khulan.write') === false) {
                  return true;
              }
      Severity: Major
      Found in classes/ModelWithKhulan.php - About 2 hrs to fix

        Method decodeKhulan has 55 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function decodeKhulan(?array $data = []): array
            {
                if (empty($data)) {
                    return [];
                }
        Severity: Major
        Found in classes/ModelWithKhulan.php - About 2 hrs to fix

          Function decodeKhulan has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              public function decodeKhulan(?array $data = []): array
              {
                  if (empty($data)) {
                      return [];
                  }
          Severity: Minor
          Found in classes/ModelWithKhulan.php - About 1 hr to fix

          Cognitive Complexity

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

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

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

          Further reading

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

              public function writeKhulan(?array $data = null, ?string $languageCode = null): bool
              {
                  if (option('bnomei.mongodb.khulan.write') === false) {
                      return true;
                  }
          Severity: Minor
          Found in classes/ModelWithKhulan.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

          There are no issues that match your filters.

          Category
          Status