GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( 125e00...775331 )
by Toby
10:03 queued 12s
created

RoleController::update()   B

Complexity

Conditions 7
Paths 48

Size

Total Lines 26
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 14
CRAP Score 7

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 26
ccs 14
cts 14
cp 1
rs 8.8333
c 0
b 0
f 0
cc 7
nc 48
nop 4
crap 7
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace BristolSU\ControlDB\Http\Controllers\Role;
4
5
use BristolSU\ControlDB\Http\Controllers\Controller;
6
use BristolSU\ControlDB\Http\Requests\Api\Role\StoreRoleRequest;
7
use BristolSU\ControlDB\Http\Requests\Api\Role\UpdateRoleRequest;
8
use BristolSU\ControlDB\Contracts\Repositories\DataRole as DataRoleRepository;
9
use BristolSU\ControlDB\Contracts\Repositories\Role as RoleRepository;
10
use BristolSU\ControlDB\Contracts\Models\Role;
11
12
/**
13
 * Handle roles
14
 */
0 ignored issues
show
Coding Style introduced by
Missing @category tag in class comment
Loading history...
Coding Style introduced by
Missing @package tag in class comment
Loading history...
Coding Style introduced by
Missing @author tag in class comment
Loading history...
Coding Style introduced by
Missing @license tag in class comment
Loading history...
Coding Style introduced by
Missing @link tag in class comment
Loading history...
15
class RoleController extends Controller
16
{
17
18
    /**
19
     * Get all roles
20
     * 
21
     * @param RoleRepository $roleRepository
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
22
     * @return Role[]|\Illuminate\Support\Collection
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
23
     */
24 1
    public function index(RoleRepository $roleRepository)
25
    {
26 1
        return $roleRepository->all();
27
    }
28
29
    /**
30
     * Get information about a specific role
31
     * 
32
     * @param Role $role
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
33
     * @return Role
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
34
     */
35 1
    public function show(Role $role)
36
    {
37 1
        return $role;
38
    }
39
40
    /**
41
     * Create a new role
42
     * 
43
     * @param StoreRoleRequest $request
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 3 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
44
     * @param RoleRepository $roleRepository
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 5 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
45
     * @param DataRoleRepository $dataRoleRepository
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
46
     * @return Role
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
47
     */
48 2
    public function store(StoreRoleRequest $request, RoleRepository $roleRepository, DataRoleRepository $dataRoleRepository)
49
    {
50 2
        $dataRole = $dataRoleRepository->create(
51 2
            $request->input('role_name'),
52 2
            $request->input('email')
53
        );
54
        
55 2
        foreach($dataRole->getAdditionalAttributes() as $additionalAttribute) {
0 ignored issues
show
Coding Style introduced by
Expected "foreach (...) {\n"; found "foreach(...) {\n"
Loading history...
56 1
            if($request->has($additionalAttribute)) {
0 ignored issues
show
Coding Style introduced by
Expected "if (...) {\n"; found "if(...) {\n"
Loading history...
57 1
                $dataRole->saveAdditionalAttribute($additionalAttribute, $request->input($additionalAttribute));
58
            }
59
        }
60
        
61 2
        return $roleRepository->create($request->input('position_id'), $request->input('group_id'), $dataRole->id());
62
    }
63
64
    /**
65
     * Update a role
66
     * 
67
     * @param Role $role
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 15 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
68
     * @param UpdateRoleRequest $request
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 2 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
69
     * @param RoleRepository $roleRepository
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 5 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
70
     * @param DataRoleRepository $dataRoleRepository
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
71
     * @return Role
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
72
     */
73 2
    public function update(Role $role, UpdateRoleRequest $request, RoleRepository $roleRepository, DataRoleRepository $dataRoleRepository)
0 ignored issues
show
Unused Code introduced by
The parameter $dataRoleRepository is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

73
    public function update(Role $role, UpdateRoleRequest $request, RoleRepository $roleRepository, /** @scrutinizer ignore-unused */ DataRoleRepository $dataRoleRepository)

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

Loading history...
Unused Code introduced by
The parameter $roleRepository is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

73
    public function update(Role $role, UpdateRoleRequest $request, /** @scrutinizer ignore-unused */ RoleRepository $roleRepository, DataRoleRepository $dataRoleRepository)

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

Loading history...
74
    {
75 2
        $dataRole = $role->data();
76
77 2
        if($request->input('role_name') !== null) {
0 ignored issues
show
Coding Style introduced by
Expected "if (...) {\n"; found "if(...) {\n"
Loading history...
78 2
            $dataRole->setRoleName($request->input('role_name'));
79
        }
80 2
        if($request->input('email') !== null) {
0 ignored issues
show
Coding Style introduced by
Expected "if (...) {\n"; found "if(...) {\n"
Loading history...
81 2
            $dataRole->setEmail($request->input('email'));
82
        }
83
84 2
        if($request->input('position_id') !== null) {
0 ignored issues
show
Coding Style introduced by
Expected "if (...) {\n"; found "if(...) {\n"
Loading history...
85 1
            $role->setPositionId($request->input('position_id'));
86
        }
87
88 2
        if($request->input('group_id') !== null) {
0 ignored issues
show
Coding Style introduced by
Expected "if (...) {\n"; found "if(...) {\n"
Loading history...
89 1
            $role->setGroupId($request->input('group_id'));
90
        }
91
        
92 2
        foreach($dataRole->getAdditionalAttributes() as $additionalAttribute) {
0 ignored issues
show
Coding Style introduced by
Expected "foreach (...) {\n"; found "foreach(...) {\n"
Loading history...
93 1
            if($request->has($additionalAttribute)) {
0 ignored issues
show
Coding Style introduced by
Expected "if (...) {\n"; found "if(...) {\n"
Loading history...
94 1
                $dataRole->saveAdditionalAttribute($additionalAttribute, $request->input($additionalAttribute));
95
            }
96
        }
97
        
98 2
        return $role;
99
    }
100
101
    /**
102
     * Delete a role
103
     * 
104
     * @param Role $role
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 11 spaces after parameter type; 1 found
Loading history...
105
     * @param RoleRepository $roleRepository
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
106
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
107 1
    public function destroy(Role $role, RoleRepository $roleRepository)
108
    {
109 1
        $roleRepository->delete((int) $role->id());
110 1
    }
111
112
113
}
114