Finesse/Wired

View on GitHub
src/Relations/BelongsToMany.php

Summary

Maintainability
D
2 days
Test Coverage

File BelongsToMany.php has 338 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace Finesse\Wired\Relations;

use Finesse\MiniDB\Database;
Severity: Minor
Found in src/Relations/BelongsToMany.php - About 4 hrs to fix

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

        public function attach(
            Mapper $mapper,
            array $parents,
            array $children,
            string $onMatch,
    Severity: Major
    Found in src/Relations/BelongsToMany.php - About 3 hrs to fix

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

          protected function updateAttachmentsGroup(
              $parentId,
              $childId,
              array $parents,
              array $children,
      Severity: Minor
      Found in src/Relations/BelongsToMany.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 attach has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
      Open

          public function attach(
              Mapper $mapper,
              array $parents,
              array $children,
              string $onMatch,
      Severity: Minor
      Found in src/Relations/BelongsToMany.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 updateAttachmentsGroup has 51 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function updateAttachmentsGroup(
              $parentId,
              $childId,
              array $parents,
              array $children,
      Severity: Major
      Found in src/Relations/BelongsToMany.php - About 2 hrs to fix

        Method loadRelatives has 46 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function loadRelatives(Mapper $mapper, string $name, array $parents, \Closure $constraint = null)
            {
                if (!$parents) {
                    return;
                }
        Severity: Minor
        Found in src/Relations/BelongsToMany.php - About 1 hr to fix

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

              public function loadRelatives(Mapper $mapper, string $name, array $parents, \Closure $constraint = null)
              {
                  if (!$parents) {
                      return;
                  }
          Severity: Minor
          Found in src/Relations/BelongsToMany.php - About 1 hr to fix

          Cognitive Complexity

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

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

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

          Further reading

          Method updateAttachmentsGroup has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Wontfix

                  $parentId,
                  $childId,
                  array $parents,
                  array $children,
                  array $oldAttachments,
          Severity: Major
          Found in src/Relations/BelongsToMany.php - About 50 mins to fix

            Method __construct has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    string $modelClass,
                    string $pivotParentField,
                    string $pivotTable,
                    string $pivotChildField,
                    string $parentIdentifierField = null,
            Severity: Minor
            Found in src/Relations/BelongsToMany.php - About 45 mins to fix

              Method makeAttachmentExtraFields has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                      ModelInterface $parent,
                      ModelInterface $child,
                      $parentKey,
                      $childKey,
                      callable $extraFieldsMaker = null,
              Severity: Minor
              Found in src/Relations/BelongsToMany.php - About 45 mins to fix

                Method attach has 6 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                        Mapper $mapper,
                        array $parents,
                        array $children,
                        string $onMatch,
                        bool $detachOther,
                Severity: Minor
                Found in src/Relations/BelongsToMany.php - About 45 mins to fix

                  There are no issues that match your filters.

                  Category
                  Status