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.

UserRole   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 11
c 1
b 0
f 0
dl 0
loc 65
ccs 15
cts 15
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A removeUserFromRole() 0 3 1
A getUsersThroughRole() 0 4 1
A __construct() 0 4 1
A getRolesThroughUser() 0 4 1
A addUserToRole() 0 3 1
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace BristolSU\ControlDB\Cache\Pivots;
4
5
use BristolSU\ControlDB\Contracts\Models\Role;
6
use BristolSU\ControlDB\Contracts\Models\User;
7
use BristolSU\ControlDB\Contracts\Repositories\Pivots\UserRole as UserRoleContract;
8
use Illuminate\Contracts\Cache\Repository;
9
use Illuminate\Support\Collection;
10
11
class UserRole implements UserRoleContract
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class UserRole
Loading history...
12
{
13
14
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
15
     * @var UserRoleContract
16
     */
17
    private $userRole;
0 ignored issues
show
Coding Style introduced by
Private member variable "userRole" must be prefixed with an underscore
Loading history...
18
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
19
     * @var Repository
20
     */
21
    private $cache;
0 ignored issues
show
Coding Style introduced by
Private member variable "cache" must be prefixed with an underscore
Loading history...
22
23 30
    public function __construct(UserRoleContract $userRole, Repository $cache)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function __construct()
Loading history...
24
    {
25 30
        $this->userRole = $userRole;
26 30
        $this->cache = $cache;
27 30
    }
28
29
    /**
30
     * Get all users who are members of a role
31
     *
32
     * @param Role $role
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
33
     * @return User[]|Collection Users who are members of the role
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
34
     */
35 5
    public function getUsersThroughRole(Role $role): Collection
36
    {
37
        return $this->cache->rememberForever(static::class . '@getUsersThroughRole:' . $role->id(), function() use ($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 $this->userRole->getUsersThroughRole($role);
39 5
        });
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
    /**
43
     * Get all roles a user belongs to
44
     *
45
     * @param User $user
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
46
     * @return Role[]|Collection Roles the user is a member of
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
47
     */
48 4
    public function getRolesThroughUser(User $user): Collection
49
    {
50
        return $this->cache->rememberForever(static::class . '@getRolesThroughUser:' . $user->id(), function() use ($user) {
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...
51 4
            return $this->userRole->getRolesThroughUser($user);
52 4
        });
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...
53
    }
54
55
    /**
56
     * Add a user to a role
57
     *
58
     * @param User $user User to add to the role
59
     * @param Role $role Role to add the user to
60
     * @return void
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
61
     */
62 13
    public function addUserToRole(User $user, Role $role): void
63
    {
64 13
        $this->userRole->addUserToRole($user, $role);
65 13
    }
66
67
    /**
68
     * Remove a user from a role
69
     * @param User $user User to remove from the role
0 ignored issues
show
Coding Style introduced by
There must be exactly one blank line before the tags in a doc comment
Loading history...
70
     * @param Role $role Role to remove the user from
71
     * @return void
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
72
     */
73 5
    public function removeUserFromRole(User $user, Role $role): void
74
    {
75 5
        $this->userRole->removeUserFromRole($user, $role);
76 5
    }
77
    
78
}