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   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A all() 0 4 1
A whereID() 0 4 1
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
}