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 — development ( 0f1776...2ed88e )
by José
03:19
created

DonorController::index()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace DoeSangue\Http\Controllers;
4
5
use DoeSangue\Models\Donor;
6
use Illuminate\Http\Request;
7
8
class DonorController extends Controller
9
{
10
    /**
11
     * Display a listing of the resource.
12
     *
13
     * @return \Illuminate\Http\Response
14
     */
15
    public function index()
16
    {
17
        $donors = Donor::orderBy('id', 'desc')->get();
18
19
        return view('donors.index', compact('donors'));
20
    }
21
22
    /**
23
     * Show the form for creating a new resource.
24
     *
25
     * @return \Illuminate\Http\Response
26
     */
27
    public function create()
28
    {
29
        return view('donors.create');
30
    }
31
32
    /**
33
     * Store a newly created resource in storage.
34
     *
35
     * @param \Illuminate\Http\Request $request
36
     *
37
     * @return \Illuminate\Http\Response
38
     */
39
    public function store(Request $request)
40
    {
41
        $this->validate(
42
            $request,
43
            [
44
            'user_id' => 'required',
45
            'blood_type_id' => 'required',
46
            ]
47
        );
48
49
        $donor = new Donor();
50
        $donor->user_id = $request['user_id'];
0 ignored issues
show
Documentation introduced by
The property user_id does not exist on object<DoeSangue\Models\Donor>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
51
        $donor->blood_type_id = $request['blood_type_id'];
0 ignored issues
show
Documentation introduced by
The property blood_type_id does not exist on object<DoeSangue\Models\Donor>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
52
        $donor->save();
53
54
        return redirect()->route('user.profile');
55
    }
56
57
    /**
58
     * Display the specified resource.
59
     *
60
     * @param int $id
61
     *
62
     * @return \Illuminate\Http\Response
63
     */
64
    public function show($id)
65
    {
66
        $donor = Donor::find($id);
67
68
        return view('donors.Show', compact('donor'));
69
    }
70
71
    /**
72
     * Show the form for editing the specified resource.
73
     *
74
     * @param int $id
75
     *
76
     * @return \Illuminate\Http\Response
77
     */
78
    public function edit($id)
0 ignored issues
show
Unused Code introduced by
The parameter $id is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
79
    {
80
        return view('donors.edit');
81
    }
82
83
    /**
84
     * Update the specified resource in storage.
85
     *
86
     * @param \Illuminate\Http\Request $request
87
     * @param int                      $id
88
     *
89
     * @return \Illuminate\Http\Response
90
     */
91
    public function update(Request $request, $id)
92
    {
93
        $this->validate(
94
            $request,
95
            [
96
              ''
97
            ]
98
        );
99
        $donor = Donor::find($id);
0 ignored issues
show
Unused Code introduced by
$donor is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
100
    }
101
102
    /**
103
     * Remove the specified resource from storage.
104
     *
105
     * @param int $id
106
     *
107
     * @return \Illuminate\Http\Response
108
     */
109
    public function destroy($id)
0 ignored issues
show
Unused Code introduced by
The parameter $id is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
110
    {
111
    }
112
}
113