Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Push — master ( 70e47f...dda101 )
by Mark
07:55
created

ArticleCategoryRepository   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 25
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A whereStatusActive() 0 4 1
1
<?php
2
3
namespace App\Classes\Repositories;
4
5
use App\Model\Menu;
6
use Illuminate\Support\Collection;
7
use Illuminate\Database\Eloquent\Builder;
8
use App\Model\ArticleCategory;
9
10
/**
11
 * Class ArticleCategoryRepository
12
 *
13
 * @package App\Classes\Repositories
14
 */
15
class ArticleCategoryRepository extends BaseRepository
16
{
17
    /**
18
     * @var ArticleCategory|Builder|Collection
19
     */
20
    protected $model;
21
22
    /**
23
     * PageRepository constructor.
24
     *
25
     * @param Menu $model
0 ignored issues
show
Documentation introduced by
Consider making the type for parameter $model a bit more specific; maybe use ArticleCategory.
Loading history...
26
     */
27
    public function __construct(ArticleCategory $model)
28
    {
29
        $this->model = $model;
30
    }
31
32
    /**
33
     * @return \Illuminate\Database\Eloquent\Collection|mixed|static[]
34
     */
35
    public function whereStatusActive()
36
    {
37
        return $this->model->where('status', true)->get();
0 ignored issues
show
Bug introduced by
The method where does only exist in Illuminate\Database\Eloq...nate\Support\Collection, but not in App\Model\ArticleCategory.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
38
    }
39
}