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.

RoleController::store()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 10
c 1
b 0
f 0
nc 1
nop 6
dl 0
loc 18
ccs 11
cts 11
cp 1
crap 1
rs 9.9332
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace BristolSU\Module\AssignRoles\Http\Controllers\ParticipantApi;
4
5
use BristolSU\ControlDB\Contracts\Repositories\DataRole;
6
use BristolSU\ControlDB\Contracts\Repositories\Role;
7
use BristolSU\Module\AssignRoles\Events\RoleCreated;
8
use BristolSU\Module\AssignRoles\Http\Controllers\Controller;
9
use BristolSU\Module\AssignRoles\Http\Requests\ParticipantApi\RoleController\DestroyRequest;
10
use BristolSU\Module\AssignRoles\Http\Requests\ParticipantApi\RoleController\StoreRequest;
11
use BristolSU\Module\AssignRoles\Http\Requests\ParticipantApi\RoleController\UpdateRequest;
12
use BristolSU\Support\Activity\Activity;
13
use BristolSU\Support\Authentication\Contracts\Authentication;
14
use BristolSU\Support\ModuleInstance\ModuleInstance;
15
16
class RoleController extends Controller
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class RoleController
Loading history...
17
{
18
19 3
    public function index(Activity $activity, ModuleInstance $moduleInstance, Role $role, Authentication $authentication)
0 ignored issues
show
Unused Code introduced by
The parameter $activity 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

19
    public function index(/** @scrutinizer ignore-unused */ Activity $activity, ModuleInstance $moduleInstance, Role $role, Authentication $authentication)

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 $moduleInstance 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

19
    public function index(Activity $activity, /** @scrutinizer ignore-unused */ ModuleInstance $moduleInstance, Role $role, Authentication $authentication)

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...
Coding Style introduced by
Missing doc comment for function index()
Loading history...
20
    {
21 3
        $this->authorize('role.index');
22 2
        $roles = $role->allThroughGroup(
23 2
            $authentication->getGroup()
0 ignored issues
show
Bug introduced by
It seems like $authentication->getGroup() can also be of type null; however, parameter $group of BristolSU\ControlDB\Cont...Role::allThroughGroup() does only seem to accept BristolSU\ControlDB\Contracts\Models\Group, maybe add an additional type check? ( Ignorable by Annotation )

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

23
            /** @scrutinizer ignore-type */ $authentication->getGroup()
Loading history...
24
        );
25
        
26
        return $roles->map(function(\BristolSU\ControlDB\Contracts\Models\Role $role) {
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
27 2
            $roleArray = $role->toArray();
28 2
            $roleArray['position'] = $role->position();
29 2
            $roleArray['users'] = $role->users();
30 2
            return $roleArray;
31 2
        });
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
32
    }
33
34 7
    public function store(Activity $activity, ModuleInstance $moduleInstance, StoreRequest $request, Role $roleRepository, DataRole $dataRoleRepository, Authentication $authentication)
0 ignored issues
show
Unused Code introduced by
The parameter $activity 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

34
    public function store(/** @scrutinizer ignore-unused */ Activity $activity, ModuleInstance $moduleInstance, StoreRequest $request, Role $roleRepository, DataRole $dataRoleRepository, Authentication $authentication)

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 $moduleInstance 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

34
    public function store(Activity $activity, /** @scrutinizer ignore-unused */ ModuleInstance $moduleInstance, StoreRequest $request, Role $roleRepository, DataRole $dataRoleRepository, Authentication $authentication)

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...
Coding Style introduced by
Missing doc comment for function store()
Loading history...
35
    {
36 7
        $this->authorize('role.store');
37
        
38 6
        $dataRole = $dataRoleRepository->create(
39 6
            $request->input('role_name'),
40 6
            $request->input('email')
41
        );
42
43 6
        $role = $roleRepository->create(
44 6
            $request->input('position_id'),
45 6
            $authentication->getGroup()->id(),
46 6
            $dataRole->id()
47
        );
48
        
49 6
        event(new RoleCreated($role));
50
        
51 6
        return $role;
52
    }
53
54 2
    public function destroy(Activity $activity, ModuleInstance $moduleInstance, int $roleId, DestroyRequest $request, Role $roleRepository)
0 ignored issues
show
Unused Code introduced by
The parameter $request 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

54
    public function destroy(Activity $activity, ModuleInstance $moduleInstance, int $roleId, /** @scrutinizer ignore-unused */ DestroyRequest $request, Role $roleRepository)

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 $activity 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

54
    public function destroy(/** @scrutinizer ignore-unused */ Activity $activity, ModuleInstance $moduleInstance, int $roleId, DestroyRequest $request, Role $roleRepository)

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 $moduleInstance 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

54
    public function destroy(Activity $activity, /** @scrutinizer ignore-unused */ ModuleInstance $moduleInstance, int $roleId, DestroyRequest $request, Role $roleRepository)

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...
Coding Style introduced by
Missing doc comment for function destroy()
Loading history...
55
    {
56 2
        $this->authorize('role.delete');
57
        
58 1
        $roleRepository->delete($roleId);
59 1
    }
60
61 5
    public function update(Activity $activity, ModuleInstance $moduleInstance, int $roleId, UpdateRequest $request, Role $roleRepository, DataRole $dataRoleRepository)
0 ignored issues
show
Unused Code introduced by
The parameter $activity 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

61
    public function update(/** @scrutinizer ignore-unused */ Activity $activity, ModuleInstance $moduleInstance, int $roleId, UpdateRequest $request, Role $roleRepository, DataRole $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 $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

61
    public function update(Activity $activity, ModuleInstance $moduleInstance, int $roleId, UpdateRequest $request, Role $roleRepository, /** @scrutinizer ignore-unused */ DataRole $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 $moduleInstance 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

61
    public function update(Activity $activity, /** @scrutinizer ignore-unused */ ModuleInstance $moduleInstance, int $roleId, UpdateRequest $request, Role $roleRepository, DataRole $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...
Coding Style introduced by
Missing doc comment for function update()
Loading history...
62
    {
63 5
        $this->authorize('role.update');
64
        
65 5
        $role = $roleRepository->getById($roleId);
66 5
        $dataRole = $role->data();
67 5
        $dataRole->setEmail($request->input('email', $dataRole->email()));
68 5
        $dataRole->setRoleName($request->input('role_name', $dataRole->roleName()));
69 5
        return $dataRole;
70
    }
71
}