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.

UserGroup::getGroupsThroughUser()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 9
ccs 5
cts 5
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace BristolSU\ControlDB\Repositories\Pivots;
4
5
use BristolSU\ControlDB\Contracts\Models\Group;
6
use BristolSU\ControlDB\Contracts\Models\User;
7
use BristolSU\ControlDB\Models\Pivots\UserGroup as UserGroupPivotModel;
8
use Illuminate\Support\Collection;
9
10
/**
11
 * Handle the relationship between a group and a user
12
 */
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...
13
class UserGroup implements \BristolSU\ControlDB\Contracts\Repositories\Pivots\UserGroup
14
{
15
16
    /**
17
     * Get all users who are members of a group
18
     *
19
     * @param Group $group
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
20
     * @return User[]|Collection Users who are members of the group
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
21
     */
22 6
    public function getUsersThroughGroup(Group $group): Collection
23
    {
24 6
        $userRepository = app(\BristolSU\ControlDB\Contracts\Repositories\User::class);
25
26
        return UserGroupPivotModel::where('group_id', $group->id())->get()->map(function(UserGroupPivotModel $userGroup) use ($userRepository) {
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 5
            return $userRepository->getById((int) $userGroup->user_id);
28
        })->unique(function(User $user) {
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...
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...
29 5
            return $user->id();
30 6
        })->values();
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...
31
    }
32
33
    /**
34
     * Get all groups a user belongs to
35
     *
36
     * @param User $user
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
37
     * @return Group[]|Collection Groups 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...
38
     */
39 4
    public function getGroupsThroughUser(User $user): Collection
40
    {
41 4
        $groupRepository = app(\BristolSU\ControlDB\Contracts\Repositories\Group::class);
42
43
        return UserGroupPivotModel::where('user_id', $user->id())->get()->map(function(UserGroupPivotModel $userGroup) use ($groupRepository) {
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...
44 3
            return $groupRepository->getById((int) $userGroup->group_id);
45
        })->unique(function(Group $group) {
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...
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...
46 3
            return $group->id();
47 4
        })->values();
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...
48
    }
49
50
    /**
51
     * Add a user to a group
52
     *
53
     * @param User $user User to add to the group
0 ignored issues
show
Coding Style introduced by
Expected 2 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Expected 2 spaces after parameter name; 1 found
Loading history...
54
     * @param Group $group Group to add the user to
55
     * @return void
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
56
     */
57 12
    public function addUserToGroup(User $user, Group $group): void
58
    {
59 12
        UserGroupPivotModel::create([
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...
60 12
            'user_id' => $user->id(), 'group_id' => $group->id()
61
        ]);
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...
62 12
    }
63
64
    /**
65
     * Remove a user from a group
66
     * @param User $user User to remove from the group
0 ignored issues
show
Coding Style introduced by
There must be exactly one blank line before the tags in a doc comment
Loading history...
Coding Style introduced by
Expected 2 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Expected 2 spaces after parameter name; 1 found
Loading history...
67
     * @param Group $group Group to remove the user from
68
     * @return void
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
69
     */
70 5
    public function removeUserFromGroup(User $user, Group $group): void
71
    {
72 5
        UserGroupPivotModel::where([
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...
73 5
            'user_id' => $user->id(), 'group_id' => $group->id()
74 5
        ])->delete();
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...
75
    }
76
}