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

Test Failed
Push — development ( 3add70...a51bef )
by José
06:20
created

DonorsController::store()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
3
namespace DoeSangue\Http\Controllers\API\V1;
4
5
use Illuminate\Http\Request;
6
use DoeSangue\Http\Controllers\Controller;
7
use DoeSangue\Models\Donor;
8
9
class DonorsController extends Controller
10
{
11
    public function __construct()
12
    {
13
        $this->middleware('jwt.auth', [ 'except' => [ 'index', 'show' ] ]);
14
    }
15
16
    public function index()
17
    {
18
        $donors = Donor::with('user')->get();
0 ignored issues
show
Bug introduced by
The method get does only exist in Illuminate\Database\Eloquent\Builder, but not in Illuminate\Database\Eloquent\Model.

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...
19
20
        return response()->json($donors, 200);
21
    }
22
23
    public function show($id)
24
    {
25
26
        $donor = Donor::find($id);
27
28
        if (! $donor) {
29
            return response()->json(
30
                [
31
                    'error_code' => 404,
32
                    'error_message' => 'Donor not found!'
33
                ], 404
34
            );
35
        }
36
37
        return response()->json(
38
            [
39
                'first_name' => $donor->user->first_name,
40
                'last_name' => $donor->user->last_name,
41
                'email' => $donor->user->email,
42
                'birthdate' => $donor->user->birthdate,
43
            ]
44
        );
45
    }
46
47
    public function store()
48
    {
49
    }
50
51
    public function update()
52
    {
53
    }
54
55
    public function destroy()
56
    {
57
    }
58
}
59