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 ( 94f430...c07b11 )
by Toby
44:45 queued 28:18
created

RoleController::update()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 24
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 15
CRAP Score 3

Importance

Changes 0
Metric Value
eloc 14
c 0
b 0
f 0
dl 0
loc 24
ccs 15
cts 15
cp 1
rs 9.7998
cc 3
nc 3
nop 4
crap 3
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
use Illuminate\Http\Request;
12
use Illuminate\Pagination\LengthAwarePaginator;
13
use Illuminate\Support\Collection;
14
15
/**
16
 * Handle roles
17
 */
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...
18
class RoleController extends Controller
19
{
20
21
    /**
22
     * Get all roles
23
     *
24
     * @param Request $request
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 8 spaces after parameter type; 1 found
Loading history...
25
     * @param RoleRepository $roleRepository
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
26
     * @return LengthAwarePaginator
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
27
     */
28 2
    public function index(Request $request, RoleRepository $roleRepository)
29
    {
30 2
        $perPage = $request->input('per_page', 10);
31 2
        $page = $request->input('page', 1);
32
33 2
        return $this->paginationResponse(
34 2
            $roleRepository->paginate($page, $perPage),
35 2
            $roleRepository->count()
36
        );
37
    }
38
39
    /**
40
     * Get information about a specific role
41
     * 
42
     * @param Role $role
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
43
     * @return Role
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
44
     */
45 1
    public function show(Role $role)
46
    {
47 1
        return $role;
48
    }
49
50
    /**
51
     * Create a new role
52
     * 
53
     * @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...
54
     * @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...
55
     * @param DataRoleRepository $dataRoleRepository
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
56
     * @return Role
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
57
     */
58 2
    public function store(StoreRoleRequest $request, RoleRepository $roleRepository, DataRoleRepository $dataRoleRepository)
59
    {
60 2
        $dataRole = $dataRoleRepository->create(
61 2
            $request->input('role_name'),
62 2
            $request->input('email')
63
        );
64
        
65 2
        foreach($dataRole->getAdditionalAttributes() as $additionalAttribute) {
0 ignored issues
show
Coding Style introduced by
Expected "foreach (...) {\n"; found "foreach(...) {\n"
Loading history...
66 1
            if($request->has($additionalAttribute)) {
0 ignored issues
show
Coding Style introduced by
Expected "if (...) {\n"; found "if(...) {\n"
Loading history...
67 1
                $dataRole->saveAdditionalAttribute($additionalAttribute, $request->input($additionalAttribute));
68
            }
69
        }
70
        
71 2
        return $roleRepository->create($request->input('position_id'), $request->input('group_id'), $dataRole->id());
72
    }
73
74
    /**
75
     * Update a role
76
     * 
77
     * @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...
78
     * @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...
79
     * @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...
80
     * @param DataRoleRepository $dataRoleRepository
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
81
     * @return Role
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
82
     */
83 2
    public function update(Role $role, UpdateRoleRequest $request, RoleRepository $roleRepository, DataRoleRepository $dataRoleRepository)
84
    {
85 2
        $dataRole = $role->data();
86
        
87 2
        $dataRoleRepository->update(
88 2
            $dataRole->id(),
89 2
            $request->input('role_name', $dataRole->roleName()),
90 2
            $request->input('email', $dataRole->email()),
91
        );
92
        
93 2
        $roleRepository->update(
94 2
            $role->id(),
95 2
            $request->input('position_id', $role->positionId()),
96 2
            $request->input('group_id', $role->groupId()),
97 2
            $dataRole->id()
98
        );
99
        
100 2
        foreach($dataRole->getAdditionalAttributes() as $additionalAttribute) {
0 ignored issues
show
Coding Style introduced by
Expected "foreach (...) {\n"; found "foreach(...) {\n"
Loading history...
101 1
            if($request->has($additionalAttribute)) {
0 ignored issues
show
Coding Style introduced by
Expected "if (...) {\n"; found "if(...) {\n"
Loading history...
102 1
                $dataRole->saveAdditionalAttribute($additionalAttribute, $request->input($additionalAttribute));
103
            }
104
        }
105
        
106 2
        return $roleRepository->getById($role->id());
107
    }
108
109
    /**
110
     * Delete a role
111
     * 
112
     * @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...
113
     * @param RoleRepository $roleRepository
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
114
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
115 1
    public function destroy(Role $role, RoleRepository $roleRepository)
116
    {
117 1
        $roleRepository->delete((int) $role->id());
118 1
    }
119
120
121
}
122