rinvex/laravel-repositories

View on GitHub
src/Repositories/BaseRepository.php

Summary

Maintainability
B
6 hrs
Test Coverage

Showing 10 of 10 total issues

The class BaseRepository has an overall complexity of 58 which is very high. The configured complexity threshold is 50.
Open

abstract class BaseRepository implements RepositoryContract, CacheableContract
{
use Cacheable;
 
/**
Severity: Minor
Found in src/Repositories/BaseRepository.php by phpmd

BaseRepository has 26 functions (exceeds 20 allowed). Consider refactoring.
Open

abstract class BaseRepository implements RepositoryContract, CacheableContract
{
use Cacheable;
 
/**
Severity: Minor
Found in src/Repositories/BaseRepository.php - About 3 hrs to fix

Method prepareQuery has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Open

protected function prepareQuery($model)
{
// Set the relationships that should be eager loaded
if (! empty($this->relations)) {
$model = $model->with($this->relations);
Severity: Minor
Found in src/Repositories/BaseRepository.php - About 1 hr to fix

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

protected function prepareQuery($model)
{
// Set the relationships that should be eager loaded
if (! empty($this->relations)) {
$model = $model->with($this->relations);
Severity: Minor
Found in src/Repositories/BaseRepository.php - About 1 hr to fix

The method prepareQuery() has an NPath complexity of 6144. The configured NPath complexity threshold is 200.
Open

protected function prepareQuery($model)
{
// Set the relationships that should be eager loaded
if (! empty($this->relations)) {
$model = $model->with($this->relations);
Severity: Minor
Found in src/Repositories/BaseRepository.php by phpmd

The method prepareQuery() has a Cyclomatic Complexity of 14. The configured cyclomatic complexity threshold is 10.
Open

protected function prepareQuery($model)
{
// Set the relationships that should be eager loaded
if (! empty($this->relations)) {
$model = $model->with($this->relations);
Severity: Minor
Found in src/Repositories/BaseRepository.php by phpmd

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

if (method_exists($model = $this->createModel(), $scope = 'scope'.ucfirst($method))) {
Severity: Minor
Found in src/Repositories/BaseRepository.php by phpmd

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

if (method_exists($model = $this->createModel(), $scope = 'scope'.ucfirst($method))) {
Severity: Minor
Found in src/Repositories/BaseRepository.php by phpmd

Avoid assigning values to variables in if clauses and the like (line '483', column '58').
Open

public function __call($method, $parameters)
{
if (method_exists($model = $this->createModel(), $scope = 'scope'.ucfirst($method))) {
$this->scope($method, $parameters);
 
 
Severity: Minor
Found in src/Repositories/BaseRepository.php by phpmd

Avoid assigning values to variables in if clauses and the like (line '483', column '27').
Open

public function __call($method, $parameters)
{
if (method_exists($model = $this->createModel(), $scope = 'scope'.ucfirst($method))) {
$this->scope($method, $parameters);
 
 
Severity: Minor
Found in src/Repositories/BaseRepository.php by phpmd
Category
Status