Skip to content

Commit 3dcbfe7

Browse files
committed
OS2FORMS-359 adding address, provided available fields as const
1 parent f5be688 commit 3dcbfe7

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

src/LookupResult/CprLookupResult.php

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@
44

55
class CprLookupResult {
66

7+
const CPR = 'cpr';
8+
const NAME = 'name';
9+
const STREET = 'street';
10+
const HOUSE_NR = 'houseNr';
11+
const FLOOR = 'floor';
12+
const APARTMENT_NR = 'apartmentNr';
13+
const POSTAL_CODE = 'postalCode';
14+
const CITY = 'city';
15+
const MUNICIPALITY_CODE = 'municipalityCode';
16+
const ADDRESS = 'address';
17+
const CO_NAME = 'coName';
18+
719
/**
820
* Is request successful.
921
*
@@ -81,6 +93,13 @@ class CprLookupResult {
8193
*/
8294
protected $municipalityCode;
8395

96+
/**
97+
* Address of the person.
98+
*
99+
* @var string
100+
*/
101+
protected $address;
102+
84103
/**
85104
* CO Name of the person.
86105
*
@@ -249,6 +268,20 @@ public function setMunicipalityCode(string $municipalityCode): void {
249268
$this->municipalityCode = $municipalityCode;
250269
}
251270

271+
/**
272+
* @return string
273+
*/
274+
public function getAddress(): string {
275+
return $this->address;
276+
}
277+
278+
/**
279+
* @param string $address
280+
*/
281+
public function setAddress(string $address): void {
282+
$this->address = $address;
283+
}
284+
252285
/**
253286
* @return string
254287
*/
@@ -277,4 +310,27 @@ public function setNameAddressProtected(bool $nameAddressProtected): void {
277310
$this->nameAddressProtected = $nameAddressProtected;
278311
}
279312

313+
/**
314+
* Returns the value of the provided field.
315+
*
316+
* @param $field
317+
* Field name;
318+
*/
319+
320+
/**
321+
* Returns the value of the provided field.
322+
*
323+
* @param $field
324+
* Field name.
325+
*
326+
* @return mixed
327+
*/
328+
public function getFieldValue($field) {
329+
if (property_exists($this, $field)) {
330+
return $this->{$field};
331+
}
332+
333+
return '';
334+
}
335+
280336
}

src/Plugin/os2web/DataLookup/ServiceplatformenCPR.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ public function lookup($cpr) {
176176
$cprResult->setPostalCode($result['postnummer'] ?? '');
177177
$cprResult->setCity($result['postdistrikt'] ?? '');
178178
$cprResult->setMunicipalityCode($result['kommunekode'] ?? '');
179+
$cprResult->setAddress($cprResult->getStreet() . ' ' . $cprResult->getHouseNr() . ', ' . $cprResult->getFloor() . ', ' . $cprResult->getApartmentNr());
179180
$cprResult->setCoName($result['conavn'] ?? '');
180181
$cprResult->setNameAddressProtected($result['navneOgAdressebeskyttelse'] ?? '');
181182
}

src/Plugin/os2web/DataLookup/ServiceplatformenCPRExtended.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ public function lookup($cpr) {
109109
$cprResult->setPostalCode($address->aktuelAdresse->postnummer ?? '');
110110
$cprResult->setCity($address->aktuelAdresse->postdistrikt ?? '');
111111
$cprResult->setMunicipalityCode($address->aktuelAdresse->kommunekode ?? '');
112+
$cprResult->setAddress($address->aktuelAdresse->standardadresse ?? '');
112113
}
113114

114115
// Leaving empty, no information in webservice.

0 commit comments

Comments
 (0)