-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCprLookupResult.php
More file actions
766 lines (683 loc) · 13 KB
/
Copy pathCprLookupResult.php
File metadata and controls
766 lines (683 loc) · 13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
<?php
namespace Drupal\os2web_datalookup\LookupResult;
/**
* Representation or value object for the result of a CPR lookup.
*/
class CprLookupResult {
const CPR = 'cpr';
const NAME = 'name';
const FIRST_NAME = 'firstName';
const MIDDLE_NAME = 'middleName';
const LAST_NAME = 'lastName';
const STREET = 'street';
const HOUSE_NR = 'houseNr';
const FLOOR = 'floor';
const APARTMENT_NR = 'apartmentNr';
const POSTAL_CODE = 'postalCode';
const CITY = 'city';
const MUNICIPALITY_CODE = 'municipalityCode';
const ADDRESS = 'address';
const CO_NAME = 'coName';
/**
* Is request successful.
*
* @var bool
*/
protected bool $successful = FALSE;
/**
* Status of the request.
*
* @var string
*/
protected string $errorMessage;
/**
* CPR number.
*
* @var string
*/
protected string $cpr;
/**
* Name of the person.
*
* @var string
*/
protected string $name;
/**
* First name of the person.
*
* @var string
*/
protected string $firstName;
/**
* Middle name of the person.
*
* @var string
*/
protected string $middleName;
/**
* Last name of the person.
*
* @var string
*/
protected string $lastName;
/**
* Street of the person.
*
* @var string
*/
protected string $street;
/**
* Street house number of the person.
*
* @var string
*/
protected string $houseNr;
/**
* Floor number the person.
*
* @var string
*/
protected string $floor;
/**
* Apartment number of the person.
*
* @var string
*/
protected string $apartmentNr;
/**
* Postal code of the person.
*
* @var string
*/
protected string $postalCode;
/**
* City of the person.
*
* @var string
*/
protected string $city;
/**
* Municipality code of the person.
*
* @var string
*/
protected string $municipalityCode;
/**
* Address of the person.
*
* @var string
*/
protected string $address;
/**
* CO Name of the person.
*
* @var string
*/
protected string $coName;
/**
* Is name/address protected of the person.
*
* @var bool
*/
protected bool $nameAddressProtected = FALSE;
/**
* Array of children.
*
* @var array
*/
protected array $children = [];
/**
* Array of guardians.
*
* @var array
*/
protected array $guardians = [];
/**
* Is subscribed to digital post.
*
* @var bool
*/
protected bool $digitalPostSubscribed = FALSE;
/**
* Is alive.
*
* @var bool
*/
protected bool $alive = TRUE;
/**
* Is Danish citizen.
*
* @var bool
*/
protected bool $citizen = TRUE;
/**
* Citizenship date obtained.
*
* @var \DateTime
*/
protected \DateTime $citizenshipDate;
/**
* Citizenship country code.
*
* @var int
*/
protected $citizenshipCountryCode;
/**
* Date of birth.
*
* @var \DateTime
*/
protected \DateTime $birthDate;
/**
* Check successfulness state.
*
* @return bool
* TRUE on success else FALSE.
*/
public function isSuccessful(): bool {
return $this->successful;
}
/**
* Set state of successfulness.
*
* @param bool $successful
* The state.
*/
public function setSuccessful(bool $successful = TRUE): void {
$this->successful = $successful;
}
/**
* Get an error message.
*
* @return string
* The message.
*/
public function getErrorMessage(): string {
return $this->errorMessage;
}
/**
* Set error message.
*
* @param string $errorMessage
* The message.
*/
public function setErrorMessage(string $errorMessage): void {
$this->errorMessage = $errorMessage;
}
/**
* Get CPR number.
*
* @return string
* The number.
*/
public function getCpr(): string {
return $this->cpr;
}
/**
* Set CPR number.
*
* @param string $cpr
* The number.
*/
public function setCpr(string $cpr): void {
$this->cpr = $cpr;
}
/**
* Get name.
*
* @return string
* The name.
*/
public function getName(): string {
return $this->name;
}
/**
* Set name.
*
* @param string $name
* The name.
*/
public function setName(string $name): void {
$this->name = $name;
}
/**
* Get first name.
*
* @return string
* The first name.
*/
public function getFirstName(): string {
return $this->firstName;
}
/**
* Set first name.
*
* @param string $firstName
* The first name.
*/
public function setFirstName(string $firstName): void {
$this->firstName = $firstName;
}
/**
* Get middle name.
*
* @return string
* The middle name.
*/
public function getMiddleName(): string {
return $this->middleName;
}
/**
* Set middle name.
*
* @param string $middleName
* The middle name.
*/
public function setMiddleName(string $middleName): void {
$this->middleName = $middleName;
}
/**
* Get last name.
*
* @return string
* The last name.
*/
public function getLastName(): string {
return $this->lastName;
}
/**
* Set last name.
*
* @param string $lastName
* The last name.
*/
public function setLastName(string $lastName): void {
$this->lastName = $lastName;
}
/**
* Get street.
*
* @return string
* The street.
*/
public function getStreet(): string {
return $this->street;
}
/**
* Set street.
*
* @param string $street
* The street.
*/
public function setStreet(string $street): void {
$this->street = $street;
}
/**
* Get house number.
*
* @return string
* The number.
*/
public function getHouseNr(): string {
return $this->houseNr;
}
/**
* Set house number.
*
* @param string $houseNr
* The number.
*/
public function setHouseNr(string $houseNr): void {
$this->houseNr = $houseNr;
}
/**
* Get floor.
*
* @return string
* The floor.
*/
public function getFloor(): string {
return $this->floor;
}
/**
* Set floor.
*
* @param string $floor
* The floor.
*/
public function setFloor(string $floor): void {
$this->floor = $floor;
}
/**
* Get apartment number.
*
* @return string
* The number.
*/
public function getApartmentNr(): string {
return $this->apartmentNr;
}
/**
* Set apartment number.
*
* @param string $apartmentNr
* The number.
*/
public function setApartmentNr(string $apartmentNr): void {
$this->apartmentNr = $apartmentNr;
}
/**
* Get postal code.
*
* @return string
* The code.
*/
public function getPostalCode(): string {
return $this->postalCode;
}
/**
* Set postal code.
*
* @param string $postalCode
* The code.
*/
public function setPostalCode(string $postalCode): void {
$this->postalCode = $postalCode;
}
/**
* Get city name.
*
* @return string
* The name.
*/
public function getCity(): string {
return $this->city;
}
/**
* Set city.
*
* @param string $city
* The city name.
*/
public function setCity(string $city): void {
$this->city = $city;
}
/**
* Get municipality code.
*
* @return string
* The code.
*/
public function getMunicipalityCode(): string {
return $this->municipalityCode;
}
/**
* Set municipality code.
*
* @param string $municipalityCode
* The code.
*/
public function setMunicipalityCode(string $municipalityCode): void {
$this->municipalityCode = $municipalityCode;
}
/**
* Get address.
*
* @return string
* The address.
*/
public function getAddress(): string {
return $this->address;
}
/**
* Set address.
*
* @param string $address
* The address.
*/
public function setAddress(string $address): void {
$this->address = $address;
}
/**
* Get CO name.
*
* @return string
* The CO name.
*/
public function getCoName(): string {
return $this->coName;
}
/**
* Set CO name.
*
* @param string $coName
* The CO name to set.
*/
public function setCoName(string $coName): void {
$this->coName = $coName;
}
/**
* Check if the address is protected.
*
* @return bool
* TRUE if it is else FALSE.
*/
public function isNameAddressProtected(): bool {
return $this->nameAddressProtected;
}
/**
* Set address protected state.
*
* @param bool $nameAddressProtected
* TRUE if protected else FALSE.
*/
public function setNameAddressProtected(bool $nameAddressProtected): void {
$this->nameAddressProtected = $nameAddressProtected;
}
/**
* Returns the children.
*
* @return array
* Children array as
* [
* 0 => [
* 'cpr' => xxxxx,
* 'name' => full name,
* ],
* ...
* ].
*/
public function getChildren(): array {
return $this->children;
}
/**
* Sets the children.
*
* @param array $children
* Children array as
* [
* 0 => [
* 'cpr' => xxxxx,
* 'name' => full name,
* 'nameAddressProtected' => TRUE/FALSE
* ],
* ...
* ].
*/
public function setChildren(array $children): void {
$this->children = $children;
}
/**
* Returns the guardians.
*
* @return array
* Guardians array as
* [
* 0 => [
* 'cpr' => xxxxx,
* 'type' => type of guardian,
* 'nameAddressProtected' => TRUE/FALSE
* ],
* ...
* ].
*/
public function getGuardians(): array {
return $this->guardians;
}
/**
* Sets the guardians.
*
* @param array $guardians
* Guardians array as
* [
* 0 => [
* 'cpr' => xxxxx,
* 'type' => 1|2|3|4,
* ],
* ...
* ].
*/
public function setGuardians(array $guardians): void {
$this->guardians = $guardians;
}
/**
* Set digital post subscriber state.
*
* @param bool $digitalPostSubscribed
* The state.
*/
public function setDigitalPostSubscribed(bool $digitalPostSubscribed): void {
$this->digitalPostSubscribed = $digitalPostSubscribed;
}
/**
* Check the state of digital post subscription.
*
* @return bool
* TRUE if subscriber else FALSE.
*/
public function isDigitalPostSubscribed(): bool {
return $this->digitalPostSubscribed;
}
/**
* Check if citizen is alive.
*
* @return bool
* The living state.
*/
public function isAlive(): bool {
return $this->alive;
}
/**
* Set is alive.
*
* @param bool $alive
* TRUE if alive else FALSE.
*/
public function setAlive(bool $alive): void {
$this->alive = $alive;
}
/**
* Check if this is a citizen.
*
* @return bool
* TRUE if it is else FALSE.
*/
public function isCitizen(): bool {
return $this->citizen;
}
/**
* Set citizen.
*
* @param bool $citizen
* The citizen (TRUE or FALSE).
*/
public function setCitizen(bool $citizen): void {
$this->citizen = $citizen;
}
/**
* Get citizenship date.
*
* @return \DateTime
* The date.
*/
public function getCitizenshipDate(): \DateTime {
return $this->citizenshipDate;
}
/**
* Set citizenship date.
*
* @param \DateTime $citizenshipDate
* The date.
*/
public function setCitizenshipDate(\DateTime $citizenshipDate): void {
$this->citizenshipDate = $citizenshipDate;
}
/**
* Get citizenship country code.
*
* @return int
* The citizenship country code.
*/
public function getCitizenshipCountryCode(): int {
return $this->citizenshipCountryCode;
}
/**
* Set citizenship country code.
*
* @param int $citizenshipCountryCode
* The citizenship country code.
*/
public function setCitizenshipCountryCode(int $citizenshipCountryCode): void {
$this->citizenshipCountryCode = $citizenshipCountryCode;
}
/**
* Get birthdate.
*
* @return \DateTime
* The date.
*/
public function getBirthDate(): \DateTime {
return $this->birthDate;
}
/**
* Set birthdate.
*
* @param \DateTime $birthDate
* The date.
*/
public function setBirthDate(\DateTime $birthDate): void {
$this->birthDate = $birthDate;
}
/**
* Checks if the provided CPR is in list of guardians.
*
* @param string $cpr
* Cpr number.
*
* @return bool
* TRUE if the person has provided CPR as guardian, FALSE otherwise.
*/
public function hasGuardian(string $cpr): bool {
foreach ($this->guardians as $guardian) {
if ($guardian['cpr'] == $cpr) {
return TRUE;
}
}
return FALSE;
}
/**
* Returns the value of the provided field.
*
* @param string $field
* Field name.
*
* @return mixed
* The value of the field or the empty string.
*/
public function getFieldValue(string $field): mixed {
if (property_exists($this, $field) && isset($this->{$field})) {
return $this->{$field};
}
return '';
}
}