44
55class User
66{
7- private string $ userUuid ;
7+ private int $ sequentialId ;
8+ private ?string $ userUuid = null ;
89
910 private ?string $ firstName = null ;
1011
@@ -16,7 +17,19 @@ class User
1617
1718 private string $ password ;
1819
19- private string $ creationDate ;
20+ private ?string $ creationDate = null ;
21+
22+ public function setSequentialId (int $ sequentialId ): self
23+ {
24+ $ this ->sequentialId = $ sequentialId ;
25+
26+ return $ this ;
27+ }
28+
29+ public function getSequentialId (): int
30+ {
31+ return $ this ->sequentialId ;
32+ }
2033
2134 public function setUserUuid (string $ userUuid ) :self
2235 {
@@ -25,7 +38,7 @@ public function setUserUuid(string $userUuid) :self
2538 return $ this ;
2639 }
2740
28- public function getUserUuid (): string
41+ public function getUserUuid (): ? string
2942 {
3043 return $ this ->userUuid ;
3144 }
@@ -97,8 +110,52 @@ public function setCreationDate(string $creationDate): self
97110 return $ this ;
98111 }
99112
100- public function getCreationDate (): string
113+ public function getCreationDate (): ? string
101114 {
102115 return $ this ->creationDate ;
103116 }
117+
118+ public function unserialize (?array $ data ): self
119+ {
120+ if (!empty ($ data ['id ' ])) {
121+ $ this ->setSequentialId ($ data ['id ' ]);
122+ }
123+
124+ if (!empty ($ data ['user_uuid ' ])) {
125+ $ this ->setUserUuid ($ data ['user_uuid ' ]);
126+ }
127+
128+ if (!empty ($ data ['first_name ' ])) {
129+ $ this ->setFirstName ($ data ['first_name ' ]);
130+ }
131+
132+ if (!empty ($ data ['last_name ' ])) {
133+ $ this ->setLastName ($ data ['last_name ' ]);
134+ }
135+
136+ if (!empty ($ data ['email ' ])) {
137+ $ this ->setEmail ($ data ['email ' ]);
138+ }
139+
140+ if (!empty ($ data ['phone ' ])) {
141+ $ this ->setPhone ($ data ['phone ' ]);
142+ }
143+
144+ if (!empty ($ data ['password ' ])) {
145+ $ this ->setPassword ($ data ['password ' ]);
146+ }
147+
148+ if (!empty ($ data ['created_date ' ])) {
149+ $ this ->setCreationDate ($ data ['created_date ' ]);
150+ }
151+
152+ return $ this ;
153+ }
154+
155+ // public function serialize(): array
156+ // {
157+ // // optional. we could also only return the properties we want to make it safe
158+ // // (not all properties should indeed be returned)
159+ // return get_object_vars($this);
160+ // }
104161}
0 commit comments