1 | <?php |
||||
2 | |||||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||||
3 | |||||
4 | namespace BristolSU\ControlDB\Traits; |
||||
5 | |||||
6 | |||||
7 | use BristolSU\ControlDB\Contracts\Models\Role; |
||||
8 | use BristolSU\ControlDB\Contracts\Repositories\DataRole; |
||||
9 | use Illuminate\Database\Eloquent\ModelNotFoundException; |
||||
10 | |||||
11 | /** |
||||
12 | * Implements methods to the data role interface using repositories |
||||
13 | */ |
||||
0 ignored issues
–
show
|
|||||
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()); |
|||
0 ignored issues
–
show
It seems like
id() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
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 |
||||
0 ignored issues
–
show
|
|||||
35 | */ |
||||
0 ignored issues
–
show
|
|||||
36 | 2 | public function setEmail(?string $email): void |
|||
37 | { |
||||
38 | 2 | app(DataRole::class)->update($this->id(), $this->roleName(), $email); |
|||
0 ignored issues
–
show
It seems like
roleName() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
39 | 2 | } |
|||
40 | |||||
41 | |||||
42 | /** |
||||
43 | * Set a name for the role |
||||
44 | * |
||||
45 | * @param string|null $roleName |
||||
0 ignored issues
–
show
|
|||||
46 | */ |
||||
0 ignored issues
–
show
|
|||||
47 | 2 | public function setRoleName(?string $roleName): void |
|||
48 | { |
||||
49 | 2 | app(DataRole::class)->update($this->id(), $roleName, $this->email()); |
|||
0 ignored issues
–
show
It seems like
email() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
50 | |||||
51 | } |
||||
52 | } |