1
|
|
|
<?php |
2
|
|
|
namespace MrPrompt\ShipmentCommon\Base; |
3
|
|
|
|
4
|
|
|
use DateTime; |
5
|
|
|
|
6
|
|
|
/** |
7
|
|
|
* |
8
|
|
|
* @author Thiago Paes <[email protected]> |
9
|
|
|
*/ |
10
|
|
|
class Person |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* @var string |
14
|
|
|
*/ |
15
|
|
|
private $name = ''; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @var Document |
19
|
|
|
*/ |
20
|
|
|
private $document; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @var Email |
24
|
|
|
*/ |
25
|
|
|
private $email; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var Phone |
29
|
|
|
*/ |
30
|
|
|
private $cellPhone; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @var Phone |
34
|
|
|
*/ |
35
|
|
|
private $homePhone; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @var Phone |
39
|
|
|
*/ |
40
|
|
|
private $homePhoneSecondary; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* |
44
|
|
|
* @var string |
45
|
|
|
*/ |
46
|
|
|
private $fatherName; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* |
50
|
|
|
* @var string |
51
|
|
|
*/ |
52
|
|
|
private $motherName; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Person type |
56
|
|
|
* |
57
|
|
|
* F = Física |
58
|
|
|
* J = Jurídica |
59
|
|
|
* |
60
|
|
|
* @var string |
61
|
|
|
*/ |
62
|
|
|
private $person = 'F'; |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Salaried situation |
66
|
|
|
* |
67
|
|
|
* A = active |
68
|
|
|
* I = inactive |
69
|
|
|
*/ |
70
|
|
|
private $salaried = 'A'; |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Birth |
74
|
|
|
* |
75
|
|
|
* @var DateTime |
76
|
|
|
*/ |
77
|
|
|
private $birth; |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Address |
81
|
|
|
* |
82
|
|
|
* @var Address |
83
|
|
|
*/ |
84
|
|
|
private $address; |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @var int |
88
|
|
|
*/ |
89
|
|
|
private $code; |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* Constructor |
93
|
|
|
* |
94
|
|
|
* @param string $person |
95
|
|
|
* @param string $salaried |
96
|
|
|
* @param DateTime $birth |
97
|
|
|
* @param Document $document |
98
|
|
|
* @param Address $address |
99
|
|
|
* @param Email $email |
100
|
|
|
* @param int $code |
101
|
|
|
*/ |
102
|
29 |
|
public function __construct( |
103
|
|
|
string $person = 'F', |
104
|
|
|
string $salaried = 'A', |
105
|
|
|
DateTime $birth = null, |
106
|
|
|
Document $document = null, |
107
|
|
|
Address $address = null, |
108
|
|
|
Email $email = null, |
109
|
|
|
int $code = 0 |
110
|
|
|
) { |
111
|
29 |
|
$this->person = $person; |
112
|
29 |
|
$this->salaried = $address; |
|
|
|
|
113
|
29 |
|
$this->birth = $birth ?? new DateTime(); |
114
|
29 |
|
$this->document = $document ?? new Document(); |
115
|
29 |
|
$this->address = $address ?? new Address(); |
116
|
29 |
|
$this->email = $email ?? new Email(); |
117
|
29 |
|
$this->code = $code; |
118
|
29 |
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* @return Document |
122
|
|
|
*/ |
123
|
1 |
|
public function getDocument(): Document |
124
|
|
|
{ |
125
|
1 |
|
return $this->document; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* @param Document $document |
130
|
|
|
*/ |
131
|
1 |
|
public function setDocument(Document $document) |
132
|
|
|
{ |
133
|
1 |
|
$this->document = $document; |
134
|
1 |
|
} |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* @return Phone |
138
|
|
|
*/ |
139
|
1 |
|
public function getHomePhone(): Phone |
140
|
|
|
{ |
141
|
1 |
|
return $this->homePhone; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* @param Phone $homePhone |
146
|
|
|
*/ |
147
|
1 |
|
public function setHomePhone(Phone $homePhone) |
148
|
|
|
{ |
149
|
1 |
|
$this->homePhone = $homePhone; |
150
|
1 |
|
} |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* @return Phone |
154
|
|
|
*/ |
155
|
1 |
|
public function getHomePhoneSecondary(): Phone |
156
|
|
|
{ |
157
|
1 |
|
return $this->homePhoneSecondary; |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
/** |
161
|
|
|
* @param Phone $homePhone |
162
|
|
|
*/ |
163
|
1 |
|
public function setHomePhoneSecondary(Phone $homePhone) |
164
|
|
|
{ |
165
|
1 |
|
$this->homePhoneSecondary = $homePhone; |
166
|
1 |
|
} |
167
|
|
|
|
168
|
|
|
/** |
169
|
|
|
* @return string |
170
|
|
|
*/ |
171
|
1 |
|
public function getName(): string |
172
|
|
|
{ |
173
|
1 |
|
return $this->name; |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
/** |
177
|
|
|
* @param string $name |
178
|
|
|
*/ |
179
|
1 |
|
public function setName(string $name) |
180
|
|
|
{ |
181
|
1 |
|
$this->name = $name; |
182
|
1 |
|
} |
183
|
|
|
|
184
|
|
|
/** |
185
|
|
|
* @return Email |
186
|
|
|
*/ |
187
|
1 |
|
public function getEmail(): Email |
188
|
|
|
{ |
189
|
1 |
|
return $this->email; |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
/** |
193
|
|
|
* @param Email $email |
194
|
|
|
*/ |
195
|
1 |
|
public function setEmail(Email $email) |
196
|
|
|
{ |
197
|
1 |
|
$this->email = $email; |
198
|
1 |
|
} |
199
|
|
|
|
200
|
|
|
/** |
201
|
|
|
* @return Phone |
202
|
|
|
*/ |
203
|
1 |
|
public function getCellPhone(): Phone |
204
|
|
|
{ |
205
|
1 |
|
return $this->cellPhone; |
206
|
|
|
} |
207
|
|
|
|
208
|
|
|
/** |
209
|
|
|
* @param Phone $cellPhone |
210
|
|
|
*/ |
211
|
1 |
|
public function setCellPhone(Phone $cellPhone) |
212
|
|
|
{ |
213
|
1 |
|
$this->cellPhone = $cellPhone; |
214
|
1 |
|
} |
215
|
|
|
|
216
|
|
|
/** |
217
|
|
|
* @return the $fatherName |
218
|
|
|
*/ |
219
|
1 |
|
public function getFatherName(): string |
220
|
|
|
{ |
221
|
1 |
|
return $this->fatherName; |
222
|
|
|
} |
223
|
|
|
|
224
|
|
|
/** |
225
|
|
|
* @param string $fatherName |
226
|
|
|
*/ |
227
|
1 |
|
public function setFatherName(string $fatherName) |
228
|
|
|
{ |
229
|
1 |
|
$this->fatherName = $fatherName; |
230
|
1 |
|
} |
231
|
|
|
|
232
|
|
|
/** |
233
|
|
|
* @return the $motherName |
234
|
|
|
*/ |
235
|
1 |
|
public function getMotherName(): string |
236
|
|
|
{ |
237
|
1 |
|
return $this->motherName; |
238
|
|
|
} |
239
|
|
|
|
240
|
|
|
/** |
241
|
|
|
* @param string $motherName |
242
|
|
|
*/ |
243
|
1 |
|
public function setMotherName(string $motherName) |
244
|
|
|
{ |
245
|
1 |
|
$this->motherName = $motherName; |
246
|
1 |
|
} |
247
|
|
|
|
248
|
|
|
/** |
249
|
|
|
* @return the $person |
250
|
|
|
*/ |
251
|
1 |
|
public function getPerson(): string |
252
|
|
|
{ |
253
|
1 |
|
return $this->person; |
254
|
|
|
} |
255
|
|
|
|
256
|
|
|
/** |
257
|
|
|
* @param string $person |
258
|
|
|
*/ |
259
|
1 |
|
public function setPerson(string $person = 'F') |
260
|
|
|
{ |
261
|
1 |
|
$this->person = $person; |
262
|
1 |
|
} |
263
|
|
|
|
264
|
|
|
/** |
265
|
|
|
* @return mixed |
266
|
|
|
*/ |
267
|
1 |
|
public function getSalaried(): string |
268
|
|
|
{ |
269
|
1 |
|
return $this->salaried; |
270
|
|
|
} |
271
|
|
|
|
272
|
|
|
/** |
273
|
|
|
* @param mixed $salaried |
274
|
|
|
*/ |
275
|
1 |
|
public function setSalaried(string $salaried = 'A') |
276
|
|
|
{ |
277
|
1 |
|
$this->salaried = $salaried; |
278
|
1 |
|
} |
279
|
|
|
|
280
|
|
|
/** |
281
|
|
|
* @return DateTime |
282
|
|
|
*/ |
283
|
1 |
|
public function getBirth(): DateTime |
284
|
|
|
{ |
285
|
1 |
|
return $this->birth; |
286
|
|
|
} |
287
|
|
|
|
288
|
|
|
/** |
289
|
|
|
* @param DateTime $birth |
290
|
|
|
*/ |
291
|
1 |
|
public function setBirth(DateTime $birth) |
292
|
|
|
{ |
293
|
1 |
|
$this->birth = $birth; |
294
|
1 |
|
} |
295
|
|
|
|
296
|
|
|
/** |
297
|
|
|
* @return Address |
298
|
|
|
*/ |
299
|
1 |
|
public function getAddress(): Address |
300
|
|
|
{ |
301
|
1 |
|
return $this->address; |
302
|
|
|
} |
303
|
|
|
|
304
|
|
|
/** |
305
|
|
|
* @param Address $address |
306
|
|
|
*/ |
307
|
1 |
|
public function setAddress(Address $address) |
308
|
|
|
{ |
309
|
1 |
|
$this->address = $address; |
310
|
1 |
|
} |
311
|
|
|
|
312
|
|
|
/** |
313
|
|
|
* @return int |
314
|
|
|
*/ |
315
|
1 |
|
public function getCode(): int |
316
|
|
|
{ |
317
|
1 |
|
return $this->code; |
318
|
|
|
} |
319
|
|
|
|
320
|
|
|
/** |
321
|
|
|
* @param int $code |
322
|
|
|
* @return void |
323
|
|
|
*/ |
324
|
1 |
|
public function setCode(int $code) |
325
|
|
|
{ |
326
|
1 |
|
$this->code = $code; |
327
|
1 |
|
} |
328
|
|
|
} |
329
|
|
|
|
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.
For example, imagine you have a variable
$accountId
that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to theid
property of an instance of theAccount
class. This class holds a proper account, so the id value must no longer be false.Either this assignment is in error or a type check should be added for that assignment.