reorganise class/type information

Add a separate function for each property which saves necessary
information independently. Simplify computation of labels and
simple labels to not explicitly save the labels.
This commit is contained in:
Sarah Hoffmann
2020-05-15 23:00:04 +02:00
parent 82a11cae2d
commit 1faa0f4d41
4 changed files with 482 additions and 464 deletions

View File

@@ -64,21 +64,13 @@ class AddressDetails
public function getAddressNames($sCountry = null)
{
$aAddress = array();
$aFallback = array();
foreach ($this->aAddressLines as $aLine) {
if (!self::isAddress($aLine)) {
continue;
}
$bFallback = false;
$sTypeLabel = ClassTypes\getSimpleLabel($aLine);
if ($sTypeLabel === false) {
$aTypeLabel = ClassTypes\getFallbackLabel($aLine['rank_address'],
$sCountry);
$bFallback = true;
}
$sTypeLabel = ClassTypes\getLabelTag($aLine);
$sName = null;
if (isset($aLine['localname']) && $aLine['localname']!=='') {
@@ -90,11 +82,9 @@ class AddressDetails
if (isset($sName)) {
$sTypeLabel = strtolower(str_replace(' ', '_', $sTypeLabel));
if (!isset($aAddress[$sTypeLabel])
|| (isset($aFallback[$sTypeLabel]) && $aFallback[$sTypeLabel])
|| $aLine['class'] == 'place'
) {
$aAddress[$sTypeLabel] = $sName;
$aFallback[$sTypeLabel] = $bFallback;
}
}
}