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.

RoleObserverCascadeDelete   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 86.67%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 11
c 1
b 0
f 0
dl 0
loc 35
ccs 13
cts 15
cp 0.8667
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A delete() 0 4 1
A removeUsers() 0 4 2
A __construct() 0 4 1
A removeTags() 0 4 2
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\Contracts\Models\Role;
6
use BristolSU\ControlDB\Contracts\Repositories\Pivots\Tags\RoleRoleTag;
7
use BristolSU\ControlDB\Contracts\Repositories\Pivots\UserRole;
8
9
class RoleObserverCascadeDelete
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class RoleObserverCascadeDelete
Loading history...
10
{
11
12
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
13
     * @var UserRole
14
     */
15
    private $userRole;
0 ignored issues
show
Coding Style introduced by
Private member variable "userRole" 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 RoleRoleTag
18
     */
19
    private $roleRoleTag;
0 ignored issues
show
Coding Style introduced by
Private member variable "roleRoleTag" must be prefixed with an underscore
Loading history...
20
21 8
    public function __construct(UserRole $userRole, RoleRoleTag $roleRoleTag)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function __construct()
Loading history...
22
    {
23 8
        $this->userRole = $userRole;
24 8
        $this->roleRoleTag = $roleRoleTag;
25 8
    }
26
27 1
    public function delete(Role $role)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function delete()
Loading history...
28
    {
29 1
        $this->removeUsers($role);
30 1
        $this->removeTags($role);
31 1
    }
32
33 1
    private function removeUsers(Role $role)
0 ignored issues
show
Coding Style introduced by
Private method name "RoleObserverCascadeDelete::removeUsers" must be prefixed with an underscore
Loading history...
Coding Style introduced by
Missing doc comment for function removeUsers()
Loading history...
34
    {
35 1
        foreach($this->userRole->getUsersThroughRole($role) as $user) {
0 ignored issues
show
Coding Style introduced by
Expected "foreach (...) {\n"; found "foreach(...) {\n"
Loading history...
36
            $this->userRole->removeUserFromRole($user, $role);
37
        }
38 1
    }
39
40 1
    private function removeTags(Role $role)
0 ignored issues
show
Coding Style introduced by
Private method name "RoleObserverCascadeDelete::removeTags" must be prefixed with an underscore
Loading history...
Coding Style introduced by
Missing doc comment for function removeTags()
Loading history...
41
    {
42 1
        foreach($this->roleRoleTag->getTagsThroughRole($role) as $tag) {
0 ignored issues
show
Coding Style introduced by
Expected "foreach (...) {\n"; found "foreach(...) {\n"
Loading history...
43
            $this->roleRoleTag->removeTagFromRole($tag, $role);
44
        }
45 1
    }
46
47
}