laravel/framework

View on GitHub
src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php

Summary

Maintainability
F
3 days
Test Coverage

File HasRelationships.php has 368 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php

namespace Illuminate\Database\Eloquent\Concerns;

use Closure;
Severity: Minor
Found in src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php - About 4 hrs to fix

    Method newMorphToMany has 10 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        protected function newMorphToMany(Builder $query, Model $parent, $name, $table, $foreignPivotKey,
                                          $relatedPivotKey, $parentKey, $relatedKey,
                                          $relationName = null, $inverse = false)
    Severity: Major
    Found in src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php - About 1 hr to fix

      Method morphToMany has 9 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          public function morphToMany($related, $name, $table = null, $foreignPivotKey = null,
                                      $relatedPivotKey = null, $parentKey = null,
                                      $relatedKey = null, $relation = null, $inverse = false)
      Severity: Major
      Found in src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php - About 1 hr to fix

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

            public function morphedByMany($related, $name, $table = null, $foreignPivotKey = null,
                                          $relatedPivotKey = null, $parentKey = null, $relatedKey = null, $relation = null)
        Severity: Major
        Found in src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php - About 1 hr to fix

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

              protected function newBelongsToMany(Builder $query, Model $parent, $table, $foreignPivotKey, $relatedPivotKey,
                                                  $parentKey, $relatedKey, $relationName = null)
          Severity: Major
          Found in src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php - About 1 hr to fix

            Method belongsToMany has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                public function belongsToMany($related, $table = null, $foreignPivotKey = null, $relatedPivotKey = null,
                                              $parentKey = null, $relatedKey = null, $relation = null)
            Severity: Major
            Found in src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php - About 50 mins to fix

              Method newHasOneThrough has 7 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  protected function newHasOneThrough(Builder $query, Model $farParent, Model $throughParent, $firstKey, $secondKey, $localKey, $secondLocalKey)
              Severity: Major
              Found in src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php - About 50 mins to fix

                Method newHasManyThrough has 7 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    protected function newHasManyThrough(Builder $query, Model $farParent, Model $throughParent, $firstKey, $secondKey, $localKey, $secondLocalKey)
                Severity: Major
                Found in src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php - About 50 mins to fix

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

                      protected function newMorphTo(Builder $query, Model $parent, $foreignKey, $ownerKey, $type, $relation)
                  Severity: Minor
                  Found in src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php - About 45 mins to fix

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

                        public function hasManyThrough($related, $through, $firstKey = null, $secondKey = null, $localKey = null, $secondLocalKey = null)
                    Severity: Minor
                    Found in src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php - About 45 mins to fix

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

                          public function hasOneThrough($related, $through, $firstKey = null, $secondKey = null, $localKey = null, $secondLocalKey = null)
                      Severity: Minor
                      Found in src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php - About 45 mins to fix

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

                            protected function newMorphOne(Builder $query, Model $parent, $type, $id, $localKey)
                        Severity: Minor
                        Found in src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php - About 35 mins to fix

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

                              protected function morphInstanceTo($target, $name, $type, $id, $ownerKey)
                          Severity: Minor
                          Found in src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php - About 35 mins to fix

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

                                protected function newBelongsTo(Builder $query, Model $child, $foreignKey, $ownerKey, $relation)
                            Severity: Minor
                            Found in src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php - About 35 mins to fix

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

                                  public function morphMany($related, $name, $type = null, $id = null, $localKey = null)
                              Severity: Minor
                              Found in src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php - About 35 mins to fix

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

                                    protected function newMorphMany(Builder $query, Model $parent, $type, $id, $localKey)
                                Severity: Minor
                                Found in src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php - About 35 mins to fix

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

                                      public function morphOne($related, $name, $type = null, $id = null, $localKey = null)
                                  Severity: Minor
                                  Found in src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php - About 35 mins to fix

                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                    Open

                                        public function morphMany($related, $name, $type = null, $id = null, $localKey = null)
                                        {
                                            $instance = $this->newRelatedInstance($related);
                                    
                                            // Here we will gather up the morph type and ID for the relationship so that we
                                    src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php on lines 179..190

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 142.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                    Open

                                        public function morphOne($related, $name, $type = null, $id = null, $localKey = null)
                                        {
                                            $instance = $this->newRelatedInstance($related);
                                    
                                            [$type, $id] = $this->getMorphs($name, $type, $id);
                                    src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php on lines 470..484

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 142.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                    Open

                                        public function hasManyThrough($related, $through, $firstKey = null, $secondKey = null, $localKey = null, $secondLocalKey = null)
                                        {
                                            $through = $this->newRelatedThroughInstance($through);
                                    
                                            $firstKey = $firstKey ?: $this->getForeignKey();
                                    src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php on lines 137..150

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 139.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                    Open

                                        public function hasOneThrough($related, $through, $firstKey = null, $secondKey = null, $localKey = null, $secondLocalKey = null)
                                        {
                                            $through = $this->newRelatedThroughInstance($through);
                                    
                                            $firstKey = $firstKey ?: $this->getForeignKey();
                                    src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php on lines 424..441

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 139.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                    Open

                                        public function hasOne($related, $foreignKey = null, $localKey = null)
                                        {
                                            $instance = $this->newRelatedInstance($related);
                                    
                                            $foreignKey = $foreignKey ?: $this->getForeignKey();
                                    Severity: Minor
                                    Found in src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php and 1 other location - About 55 mins to fix
                                    src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php on lines 386..397

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 99.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    Similar blocks of code found in 2 locations. Consider refactoring.
                                    Open

                                        public function hasMany($related, $foreignKey = null, $localKey = null)
                                        {
                                            $instance = $this->newRelatedInstance($related);
                                    
                                            $foreignKey = $foreignKey ?: $this->getForeignKey();
                                    Severity: Minor
                                    Found in src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php and 1 other location - About 55 mins to fix
                                    src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php on lines 101..110

                                    Duplicated Code

                                    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                    Tuning

                                    This issue has a mass of 99.

                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                    Refactorings

                                    Further Reading

                                    There are no issues that match your filters.

                                    Category
                                    Status