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.

UserBelongsToGroup::message()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
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\Group;
6
use BristolSU\ControlDB\Contracts\Models\User;
7
use BristolSU\ControlDB\Contracts\Repositories\User as UserRepository;
8
use BristolSU\Support\Authentication\Contracts\Authentication;
9
use Illuminate\Contracts\Validation\Rule;
10
11
/**
12
 * Is the user a member of the group
13
 * 
14
 * @package BristolSU\Module\AssignRoles\Rules
15
 */
0 ignored issues
show
Coding Style introduced by
Missing @category 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 UserBelongsToGroup implements Rule
17
{
18
19
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
20
     * @var Authentication
21
     */
22
    private $authentication;
0 ignored issues
show
Coding Style introduced by
Private member variable "authentication" must be prefixed with an underscore
Loading history...
23
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
24
     * @var UserRepository
25
     */
26
    private $userRepository;
0 ignored issues
show
Coding Style introduced by
Private member variable "userRepository" must be prefixed with an underscore
Loading history...
27
28 7
    public function __construct(Authentication $authentication, UserRepository $userRepository)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function __construct()
Loading history...
29
    {
30 7
        $this->authentication = $authentication;
31 7
        $this->userRepository = $userRepository;
32 7
    }
33
34
    /**
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...
35
     * @inheritDoc
36
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
37 7
    public function passes($attribute, $value)
38
    {
39 7
        $user = app(UserRepository::class)->getById((int) $value);
0 ignored issues
show
Unused Code introduced by
The assignment to $user is dead and can be removed.
Loading history...
40 7
        $groupToMatch = $this->group();
41
        return $this->userRepository->getById($value)->groups()->filter(function(Group $group) use ($groupToMatch) {
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...
42 6
            return $group->id() === $groupToMatch->id();
43 7
        })->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...
44
    }
45
    
46 7
    protected function group() 
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function group()
Loading history...
47
    {
48 7
        return $this->authentication->getGroup();
49
    }
50
51
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
52
     * @inheritDoc
53
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
54 1
    public function message()
55
    {
56 1
        return 'The user is not a member of the group';
57
    }
58
}