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 — develop ( e6912b...498113 )
by Toby
13:04
created

UserObserverCascadeDelete   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Test Coverage

Coverage 85.71%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 8
eloc 16
c 1
b 0
f 0
dl 0
loc 48
ccs 18
cts 21
cp 0.8571
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A removeGroups() 0 4 2
A __construct() 0 5 1
A removeRoles() 0 4 2
A removeTags() 0 4 2
A delete() 0 5 1
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace BristolSU\ControlDB\Observers;
4
5
use BristolSU\ControlDB\Cache\Pivots\Tags\UserUserTag;
6
use BristolSU\ControlDB\Contracts\Models\User;
7
use BristolSU\ControlDB\Contracts\Repositories\Pivots\UserGroup;
8
use BristolSU\ControlDB\Contracts\Repositories\Pivots\UserRole;
9
10
class UserObserverCascadeDelete
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class UserObserverCascadeDelete
Loading history...
11
{
12
13
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
14
     * @var UserGroup
15
     */
16
    private $userGroup;
0 ignored issues
show
Coding Style introduced by
Private member variable "userGroup" must be prefixed with an underscore
Loading history...
17
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
18
     * @var UserUserTag
19
     */
20
    private $userUserTag;
0 ignored issues
show
Coding Style introduced by
Private member variable "userUserTag" must be prefixed with an underscore
Loading history...
21
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
22
     * @var UserRole
23
     */
24
    private $userRole;
0 ignored issues
show
Coding Style introduced by
Private member variable "userRole" must be prefixed with an underscore
Loading history...
25
26 4
    public function __construct(UserGroup $userGroup, UserRole $userRole, UserUserTag $userUserTag)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function __construct()
Loading history...
27
    {
28 4
        $this->userGroup = $userGroup;
29 4
        $this->userUserTag = $userUserTag;
30 4
        $this->userRole = $userRole;
31 4
    }
32
33 1
    public function delete(User $user)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function delete()
Loading history...
34
    {
35 1
        $this->removeGroups($user);
36 1
        $this->removeTags($user);
37 1
        $this->removeRoles($user);
38 1
    }
39
40 1
    private function removeGroups(User $user)
0 ignored issues
show
Coding Style introduced by
Private method name "UserObserverCascadeDelete::removeGroups" must be prefixed with an underscore
Loading history...
Coding Style introduced by
Missing doc comment for function removeGroups()
Loading history...
41
    {
42 1
        foreach($this->userGroup->getGroupsThroughUser($user) as $group) {
0 ignored issues
show
Coding Style introduced by
Expected "foreach (...) {\n"; found "foreach(...) {\n"
Loading history...
43
            $this->userGroup->removeUserFromGroup($user, $group);
44
        }
45 1
    }
46
47 1
    private function removeTags(User $user)
0 ignored issues
show
Coding Style introduced by
Private method name "UserObserverCascadeDelete::removeTags" must be prefixed with an underscore
Loading history...
Coding Style introduced by
Missing doc comment for function removeTags()
Loading history...
48
    {
49 1
        foreach($this->userUserTag->getTagsThroughUser($user) as $tag) {
0 ignored issues
show
Coding Style introduced by
Expected "foreach (...) {\n"; found "foreach(...) {\n"
Loading history...
50
            $this->userUserTag->removeTagFromUser($tag, $user);
51
        }
52 1
    }
53
54 1
    private function removeRoles(User $user)
0 ignored issues
show
Coding Style introduced by
Private method name "UserObserverCascadeDelete::removeRoles" must be prefixed with an underscore
Loading history...
Coding Style introduced by
Missing doc comment for function removeRoles()
Loading history...
55
    {
56 1
        foreach($this->userRole->getRolesThroughUser($user) as $role) {
0 ignored issues
show
Coding Style introduced by
Expected "foreach (...) {\n"; found "foreach(...) {\n"
Loading history...
57
            $this->userRole->removeUserFromRole($user, $role);
58
        }
59 1
    }
60
61
}