Skip to content

Commit

Permalink
OS-53 CPR full address
Browse files Browse the repository at this point in the history
  • Loading branch information
stankut committed Jun 1, 2023
1 parent e5c06ce commit ae8cb5a
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/Plugin/os2web/DataLookup/ServiceplatformenCPRExtended.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,23 @@ public function lookup($cpr, $allowCprTestModeReplace = TRUE) {
$cprResult->setPostalCode($address->aktuelAdresse->postnummer ?? '');
$cprResult->setCity($address->aktuelAdresse->postdistrikt ?? '');
$cprResult->setMunicipalityCode($address->aktuelAdresse->kommunekode ?? '');
$cprResult->setAddress($address->aktuelAdresse->standardadresse ?? '');

// Composing full address in one line.
$address = $cprResult->getStreet();
if ($cprResult->getHouseNr()) {
$address .= ' ' . $cprResult->getHouseNr();
}
if ($cprResult->getFloor()) {
$address .= ' ' . $cprResult->getFloor();
}
if ($cprResult->getApartmentNr()) {
$address .= ' ' . $cprResult->getApartmentNr();
}
if ($cprResult->getPostalCode() && $cprResult->getCity()) {
$address .= ', ' . $cprResult->getPostalCode() . ' ' . $cprResult->getCity();
}

$cprResult->setAddress($address ?? '');
}

$relationship = $result['relationer'];
Expand Down

0 comments on commit ae8cb5a

Please sign in to comment.