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\User; |
||||||||||
8 | use DateTime; |
||||||||||
9 | use Illuminate\Database\Eloquent\ModelNotFoundException; |
||||||||||
10 | |||||||||||
11 | /** |
||||||||||
12 | * Implements methods to the data user interface using repositories |
||||||||||
13 | */ |
||||||||||
0 ignored issues
–
show
|
|||||||||||
14 | trait DataUserTrait |
||||||||||
15 | { |
||||||||||
16 | |||||||||||
17 | /** |
||||||||||
18 | * Get the user using the data user |
||||||||||
19 | * |
||||||||||
20 | * @return User|null |
||||||||||
21 | */ |
||||||||||
22 | 2 | public function user(): ?User |
|||||||||
23 | { |
||||||||||
24 | try { |
||||||||||
25 | 2 | return app(\BristolSU\ControlDB\Contracts\Repositories\User::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 users first name |
||||||||||
33 | * |
||||||||||
34 | * @param string|null $firstName |
||||||||||
0 ignored issues
–
show
|
|||||||||||
35 | */ |
||||||||||
0 ignored issues
–
show
|
|||||||||||
36 | 2 | public function setFirstName(?string $firstName): void |
|||||||||
37 | { |
||||||||||
38 | 2 | app(\BristolSU\ControlDB\Contracts\Repositories\DataUser::class)->update( |
|||||||||
39 | 2 | $this->id(), $firstName, $this->lastName(), $this->email(), $this->dob(), $this->preferredName() |
|||||||||
0 ignored issues
–
show
It seems like
lastName() 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
![]() 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
![]() It seems like
preferredName() 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
![]() It seems like
dob() 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
![]() |
|||||||||||
40 | ); |
||||||||||
41 | 2 | } |
|||||||||
42 | |||||||||||
43 | /** |
||||||||||
44 | * Set the users last name |
||||||||||
45 | * |
||||||||||
46 | * @param string|null $lastName |
||||||||||
0 ignored issues
–
show
|
|||||||||||
47 | */ |
||||||||||
0 ignored issues
–
show
|
|||||||||||
48 | 2 | public function setLastName(?string $lastName): void |
|||||||||
49 | { |
||||||||||
50 | 2 | app(\BristolSU\ControlDB\Contracts\Repositories\DataUser::class)->update( |
|||||||||
51 | 2 | $this->id(), $this->firstName(), $lastName, $this->email(), $this->dob(), $this->preferredName() |
|||||||||
0 ignored issues
–
show
It seems like
firstName() 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
![]() |
|||||||||||
52 | ); |
||||||||||
53 | 2 | } |
|||||||||
54 | |||||||||||
55 | /** |
||||||||||
56 | * Set the users email |
||||||||||
57 | * |
||||||||||
58 | * @param string|null $email |
||||||||||
0 ignored issues
–
show
|
|||||||||||
59 | */ |
||||||||||
0 ignored issues
–
show
|
|||||||||||
60 | 2 | public function setEmail(?string $email): void |
|||||||||
61 | { |
||||||||||
62 | 2 | app(\BristolSU\ControlDB\Contracts\Repositories\DataUser::class)->update( |
|||||||||
63 | 2 | $this->id(), $this->firstName(), $this->lastName(), $email, $this->dob(), $this->preferredName() |
|||||||||
64 | ); |
||||||||||
65 | 2 | } |
|||||||||
66 | |||||||||||
67 | /** |
||||||||||
68 | * Set the date of birth attribute |
||||||||||
69 | * |
||||||||||
70 | * @param DateTime|null $dob |
||||||||||
0 ignored issues
–
show
|
|||||||||||
71 | */ |
||||||||||
0 ignored issues
–
show
|
|||||||||||
72 | 2 | public function setDob(?DateTime $dob): void |
|||||||||
73 | { |
||||||||||
74 | 2 | app(\BristolSU\ControlDB\Contracts\Repositories\DataUser::class)->update( |
|||||||||
75 | 2 | $this->id(), $this->firstName(), $this->lastName(), $this->email(), $dob, $this->preferredName() |
|||||||||
76 | ); |
||||||||||
77 | 2 | } |
|||||||||
78 | |||||||||||
79 | /** |
||||||||||
80 | * Set the preferred name for the user |
||||||||||
81 | * |
||||||||||
82 | * @param string|null $name |
||||||||||
0 ignored issues
–
show
|
|||||||||||
83 | */ |
||||||||||
0 ignored issues
–
show
|
|||||||||||
84 | 2 | public function setPreferredName(?string $name): void |
|||||||||
85 | { |
||||||||||
86 | 2 | app(\BristolSU\ControlDB\Contracts\Repositories\DataUser::class)->update( |
|||||||||
87 | 2 | $this->id(), $this->firstName(), $this->lastName(), $this->email(), $this->dob(), $name |
|||||||||
88 | ); |
||||||||||
89 | } |
||||||||||
90 | } |