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 ( 5c7169...b34131 )
by Mark
08:19 queued 05:45
created

BaseRepository::whereID()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Marky
5
 * Date: 04/01/2018
6
 * Time: 00:13
7
 */
8
9
namespace App\Classes\Repositories;
10
11
use Illuminate\Database\Eloquent\Builder;
12
use Illuminate\Support\Collection;
13
14
/**
15
 * Class BaseRepository
16
 *
17
 * @package App\Classes\Repositories
18
 */
19
class BaseRepository
20
{
21
22
    /**
23
     * @var Builder|Collection
24
     */
25
    protected $model;
26
27
    /**
28
     * @return mixed
29
     */
30
    public function all()
31
    {
32
        return $this->model->all();
0 ignored issues
show
Bug introduced by
The method all does only exist in Illuminate\Support\Collection, but not in Illuminate\Database\Eloquent\Builder.

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...
33
    }
34
35
    /**
36
     * @param int $integer
37
     * @return \Illuminate\Database\Eloquent\Model|null|static
38
     */
39
    public function whereID(int $integer)
40
    {
41
        return $this->model->where('id', $integer)->first();
42
    }
43
44
}