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.

UserBelongsToRole::passes()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 1
rs 10
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace BristolSU\Module\AssignRoles\Rules;
4
5
use BristolSU\ControlDB\Contracts\Models\Role;
6
use BristolSU\ControlDB\Contracts\Repositories\User;
7
use Illuminate\Contracts\Validation\Rule;
8
9
class UserBelongsToRole implements Rule
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class UserBelongsToRole
Loading history...
10
{
11
12
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
13
     * @var Role
14
     */
15
    private $role;
0 ignored issues
show
introduced by
The private property $role is not used, and could be removed.
Loading history...
Coding Style introduced by
Private member variable "role" must be prefixed with an underscore
Loading history...
16
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
17
     * @var User
18
     */
19
    private $userRepository;
0 ignored issues
show
Coding Style introduced by
Private member variable "userRepository" must be prefixed with an underscore
Loading history...
20
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
21
     * @var int
22
     */
23
    private $roleId;
0 ignored issues
show
Coding Style introduced by
Private member variable "roleId" must be prefixed with an underscore
Loading history...
24
25 6
    public function __construct(int $roleId, User $userRepository)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function __construct()
Loading history...
26
    {
27 6
        $this->roleId = $roleId;
28 6
        $this->userRepository = $userRepository;
29 6
        $this->roleId = $roleId;
30 6
    }
31
32
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
Coding Style introduced by
Parameter $attribute should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $value should have a doc-comment as per coding-style.
Loading history...
33
     * @inheritDoc
34
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
35 6
    public function passes($attribute, $value)
36
    {
37
        return $this->userRepository->getById($value)->roles()->filter(function(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...
38 5
            return $role->id() === $this->roleId;
39 6
        })->count() > 0;
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...
40
    }
41
42
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
43
     * @inheritDoc
44
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
45 1
    public function message()
46
    {
47 1
        return 'The user does not belong to the role';
48
    }
49
}