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.

RoleNotifier   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 132
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 11
eloc 21
c 1
b 0
f 0
dl 0
loc 132
ccs 32
cts 32
cp 1
rs 10

11 Methods

Rating   Name   Duplication   Size   Complexity  
A getByDataProviderId() 0 3 1
A count() 0 3 1
A paginate() 0 3 1
A __construct() 0 4 1
A all() 0 3 1
A create() 0 5 1
A delete() 0 5 1
A getById() 0 3 1
A update() 0 6 1
A allThroughGroup() 0 3 1
A allThroughPosition() 0 3 1
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace BristolSU\ControlDB\Observers\NotifyObservers;
4
5
use BristolSU\ControlDB\Contracts\Models\Role as RoleModel;
6
use BristolSU\ControlDB\Contracts\Repositories\Role;
7
use BristolSU\ControlDB\Contracts\Repositories\Role as RoleRepository;
8
use BristolSU\ControlDB\Observers\NotifyObservers\Framework\Notifier;
9
use BristolSU\ControlDB\Observers\NotifyObservers\Framework\ObserverStore;
10
use Illuminate\Support\Collection;
11
12
class RoleNotifier extends Notifier implements RoleRepository
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class RoleNotifier
Loading history...
13
{
14
15
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
16
     * @var RoleRepository
17
     */
18
    private $roleRepository;
0 ignored issues
show
Coding Style introduced by
Private member variable "roleRepository" must be prefixed with an underscore
Loading history...
19
20 48
    public function __construct(RoleRepository $roleRepository, ObserverStore $observerStore)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function __construct()
Loading history...
21
    {
22 48
        parent::__construct($observerStore, RoleRepository::class);
23 48
        $this->roleRepository = $roleRepository;
24 48
    }
25
26
    /**
27
     * Get a role by ID
28
     *
29
     * @param int $id
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
30
     * @return RoleModel
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
31
     */
32 25
    public function getById(int $id): RoleModel
33
    {
34 25
        return $this->roleRepository->getById($id);
35
    }
36
37
    /**
38
     * Get all roles
39
     *
40
     * @return Collection|\BristolSU\ControlDB\Contracts\Models\Role[]
41
     */
42 1
    public function all(): Collection
43
    {
44 1
        return $this->roleRepository->all();
45
    }
46
47
    /**
48
     * Get a role by data provider ID
49
     *
50
     * @param int $dataProviderId
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
51
     * @return RoleModel
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
52
     */
53 2
    public function getByDataProviderId(int $dataProviderId): RoleModel
54
    {
55 2
        return $this->roleRepository->getByDataProviderId($dataProviderId);
56
    }
57
58
    /**
59
     * Create a new role
60
     *
61
     * @param int $positionId
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
62
     * @param int $groupId
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
63
     * @param int $dataProviderId
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
64
     * @return RoleModel
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
65
     */
66 2
    public function create(int $positionId, int $groupId, int $dataProviderId): RoleModel
67
    {
68 2
        $roleModel = $this->roleRepository->create($positionId, $groupId, $dataProviderId);
69 2
        $this->notify('create', $roleModel);
70 2
        return $roleModel;
71
    }
72
73
    /**
74
     * Delete a role
75
     *
76
     * @param int $id
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
77
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
78 1
    public function delete(int $id): void
79
    {
80 1
        $roleModel = $this->getById($id);
81 1
        $this->roleRepository->delete($id);
82 1
        $this->notify('delete', $roleModel);
83 1
    }
84
85
    /**
86
     * Update the role model
87
     *
88
     * @param int $id
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
89
     * @param int $positionId
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
90
     * @param int $groupId
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
91
     * @param int $dataProviderId New data provider ID
92
     * @return RoleModel
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
93
     */
94 5
    public function update(int $id, int $positionId, int $groupId, int $dataProviderId): RoleModel
95
    {
96 5
        $oldRoleModel = $this->getById($id);
97 5
        $newRoleModel = $this->roleRepository->update($id, $positionId, $groupId, $dataProviderId);
98 5
        $this->notify('update', $oldRoleModel, $newRoleModel);
99 5
        return $newRoleModel;
100
    }
101
102
    /**
103
     * Get all roles that belong to the given group
104
     *
105
     * @param \BristolSU\ControlDB\Contracts\Models\Group $group
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
106
     * @return Collection|RoleModel[]
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
107
     */
108 4
    public function allThroughGroup(\BristolSU\ControlDB\Contracts\Models\Group $group): Collection
109
    {
110 4
        return $this->roleRepository->allThroughGroup($group);
111
    }
112
113
    /**
114
     * Get all roles that belong to the given position
115
     * @param \BristolSU\ControlDB\Contracts\Models\Position $position
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
Missing parameter comment
Loading history...
116
     * @return Collection|RoleModel[]
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
117
     */
118 4
    public function allThroughPosition(\BristolSU\ControlDB\Contracts\Models\Position $position): Collection
119
    {
120 4
        return $this->roleRepository->allThroughPosition($position);
121
    }
122
123
    /**
124
     * Paginate through all the roles
125
     *
126
     * @param int $page The page number to return
0 ignored issues
show
Coding Style introduced by
Expected 4 spaces after parameter name; 1 found
Loading history...
127
     * @param int $perPage The number of results to return per page
128
     *
129
     * @return Collection|RoleModel[]
130
     */
131 2
    public function paginate(int $page, int $perPage): Collection
132
    {
133 2
        return $this->roleRepository->paginate($page, $perPage);
134
    }
135
136
    /**
137
     * Get the number of roles
138
     *
139
     * @return int
140
     */
141 2
    public function count(): int
142
    {
143 2
        return $this->roleRepository->count();
144
    }
145
}