Total Complexity | 4 |
Total Lines | 36 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
14 | trait DataRoleTrait |
||
15 | { |
||
16 | |||
17 | /** |
||
18 | * Get the role using the data role |
||
19 | * |
||
20 | * @return Role|null |
||
21 | */ |
||
22 | 2 | public function role(): ?Role |
|
23 | { |
||
24 | try { |
||
25 | 2 | return app(\BristolSU\ControlDB\Contracts\Repositories\Role::class)->getByDataProviderId($this->id()); |
|
26 | 1 | } catch (ModelNotFoundException $e) { |
|
27 | 1 | return null; |
|
28 | } |
||
29 | } |
||
30 | |||
31 | /** |
||
32 | * Set the email of the role |
||
33 | * |
||
34 | * @param string|null $email |
||
35 | */ |
||
36 | 4 | public function setEmail(?string $email): void |
|
37 | { |
||
38 | 4 | app(DataRole::class)->update($this->id(), $this->roleName(), $email); |
|
39 | 4 | } |
|
40 | |||
41 | |||
42 | /** |
||
43 | * Set a name for the role |
||
44 | * |
||
45 | * @param string|null $roleName |
||
46 | */ |
||
47 | 4 | public function setRoleName(?string $roleName): void |
|
50 | |||
51 | } |
||
52 | } |