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

UserController::update()   B

Complexity

Conditions 8
Paths 96

Size

Total Lines 27
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 16
CRAP Score 8

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 27
ccs 16
cts 16
cp 1
rs 8.4444
c 0
b 0
f 0
cc 8
nc 96
nop 4
crap 8
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace BristolSU\ControlDB\Http\Controllers\User;
4
5
use BristolSU\ControlDB\Http\Controllers\Controller;
6
use BristolSU\ControlDB\Http\Requests\Api\User\StoreRoleRequest;
0 ignored issues
show
Bug introduced by
The type BristolSU\ControlDB\Http...i\User\StoreRoleRequest was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use BristolSU\ControlDB\Contracts\Repositories\DataUser as DataUserRepository;
8
use BristolSU\ControlDB\Contracts\Repositories\User as UserRepository;
9
use BristolSU\ControlDB\Contracts\Models\User;
10
use BristolSU\ControlDB\Http\Requests\Api\User\StoreUserRequest;
11
use Carbon\Carbon;
12
13
/**
14
 * Handle the user model
15
 */
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...
16
class UserController extends Controller
17
{
18
19
    /**
20
     * Get all users
21
     * 
22
     * @param UserRepository $userRepository
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...
23
     * @return User[]|\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...
24
     */
25 1
    public function index(UserRepository $userRepository)
26
    {
27 1
        return $userRepository->all();
28
    }
29
30
    /**
31
     * Get information about a specific user
32
     * 
33
     * @param User $user
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...
34
     * @return User
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
35
     */
36 1
    public function show(User $user)
37
    {
38 1
        return $user;
39
    }
40
41
    /**
42
     * Create a new user
43
     * 
44
     * @param StoreUserRequest $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...
45
     * @param UserRepository $userRepository
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...
46
     * @param DataUserRepository $dataUserRepository
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...
47
     * @return User
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
48
     */
49 2
    public function store(StoreUserRequest $request, UserRepository $userRepository, DataUserRepository $dataUserRepository)
50
    {
51 2
        $dataUser = $dataUserRepository->create(
52 2
            $request->input('first_name'),
53 2
            $request->input('last_name'),
54 2
            $request->input('email'),
55 2
            Carbon::make($request->input('dob')),
56 2
            $request->input('preferred_name')
57
        );
58
59 2
        foreach($dataUser->getAdditionalAttributes() as $additionalAttribute) {
0 ignored issues
show
Coding Style introduced by
Expected "foreach (...) {\n"; found "foreach(...) {\n"
Loading history...
60 1
            if($request->has($additionalAttribute)) {
0 ignored issues
show
Coding Style introduced by
Expected "if (...) {\n"; found "if(...) {\n"
Loading history...
61 1
                $dataUser->saveAdditionalAttribute($additionalAttribute, $request->input($additionalAttribute));
62
            }
63
        }
64
        
65 2
        return $userRepository->create($dataUser->id());
66
    }
67
68
    /**
69
     * Update a user
70
     * 
71
     * @param User $user
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...
72
     * @param StoreUserRequest $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...
73
     * @param UserRepository $userRepository
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...
74
     * @param DataUserRepository $dataUserRepository
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...
75
     * @return User
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
76
     */
77 2
    public function update(User $user, StoreUserRequest $request, UserRepository $userRepository, DataUserRepository $dataUserRepository)
0 ignored issues
show
Unused Code introduced by
The parameter $userRepository 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

77
    public function update(User $user, StoreUserRequest $request, /** @scrutinizer ignore-unused */ UserRepository $userRepository, DataUserRepository $dataUserRepository)

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

77
    public function update(User $user, StoreUserRequest $request, UserRepository $userRepository, /** @scrutinizer ignore-unused */ DataUserRepository $dataUserRepository)

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...
78
    {
79 2
        $dataUser = $user->data();
80
81 2
        if($request->input('first_name') !== null) {
0 ignored issues
show
Coding Style introduced by
Expected "if (...) {\n"; found "if(...) {\n"
Loading history...
82 2
            $dataUser->setFirstName($request->input('first_name'));
83
        }
84 2
        if($request->input('last_name') !== null) {
0 ignored issues
show
Coding Style introduced by
Expected "if (...) {\n"; found "if(...) {\n"
Loading history...
85 2
            $dataUser->setLastName($request->input('last_name'));
86
        }
87 2
        if($request->input('email') !== null) {
0 ignored issues
show
Coding Style introduced by
Expected "if (...) {\n"; found "if(...) {\n"
Loading history...
88 2
            $dataUser->setEmail($request->input('email'));
89
        }
90 2
        if($request->input('dob') !== null) {
0 ignored issues
show
Coding Style introduced by
Expected "if (...) {\n"; found "if(...) {\n"
Loading history...
91 2
            $dataUser->setDob(Carbon::make($request->input('dob')));
92
        }
93 2
        if($request->input('preferred_name') !== null) {
0 ignored issues
show
Coding Style introduced by
Expected "if (...) {\n"; found "if(...) {\n"
Loading history...
94 2
            $dataUser->setPreferredName($request->input('preferred_name'));
95
        }
96
97 2
        foreach($dataUser->getAdditionalAttributes() as $additionalAttribute) {
0 ignored issues
show
Coding Style introduced by
Expected "foreach (...) {\n"; found "foreach(...) {\n"
Loading history...
98 1
            if($request->has($additionalAttribute)) {
0 ignored issues
show
Coding Style introduced by
Expected "if (...) {\n"; found "if(...) {\n"
Loading history...
99 1
                $dataUser->saveAdditionalAttribute($additionalAttribute, $request->input($additionalAttribute));
100
            }
101
        }
102
103 2
        return $user;
104
    }
105
106
    /**
107
     * Delete a user
108
     * 
109
     * @param User $user
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...
110
     * @param UserRepository $userRepository
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
111
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
112 1
    public function destroy(User $user, UserRepository $userRepository)
113
    {
114 1
        $userRepository->delete((int) $user->id());
115 1
    }
116
117
118
}
119