Skip to content

Commit c1da9bb

Browse files
committed
add some more getters. make the ctor a bitttt more elegant and less duplicative
1 parent 4f15c64 commit c1da9bb

File tree

1 file changed

+46
-7
lines changed

1 file changed

+46
-7
lines changed

src/Entity/AddressValidation/AVAddress.php

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,8 @@ public function __construct(\SimpleXMLElement $xmlDoc)
6969
$this->buildingName = isset($xmlDoc->BuildingName) ? (string)$xmlDoc->BuildingName : '';
7070
if (isset($xmlDoc->AddressLine)) {
7171
for ($i = 0, $len = count($xmlDoc->AddressLine); $i < $len; $i++) {
72-
if ($i === 0) {
73-
$this->addressLine = isset($xmlDoc->AddressLine[$i]) ? (string) $xmlDoc->AddressLine[$i] : '';
74-
} elseif ($i === 1) {
75-
$this->addressLine2 = isset($xmlDoc->AddressLine[$i]) ? (string) $xmlDoc->AddressLine[$i] : '';
76-
} elseif ($i === 2) {
77-
$this->addressLine3 = isset($xmlDoc->AddressLine[$i]) ? (string) $xmlDoc->AddressLine[$i] : '';
78-
}
72+
$var = 'addressLine' . ($i > 0 ? $i + 1 : '');
73+
$this->{$var} = isset($xmlDoc->AddressLine[$i]) ? (string) $xmlDoc->AddressLine[$i] : '';
7974
}
8075
}
8176
$this->region = isset($xmlDoc->Region) ? (string)$xmlDoc->Region : '';
@@ -101,6 +96,38 @@ public function getCity()
10196
return $this->politicalDivision2;
10297
}
10398

99+
/**
100+
* @return string
101+
*/
102+
public function getRegion()
103+
{
104+
return $this->region;
105+
}
106+
107+
/**
108+
* @return string
109+
*/
110+
public function getConsigneeName()
111+
{
112+
return $this->consigneeName;
113+
}
114+
115+
/**
116+
* @return string
117+
*/
118+
public function getUrbanization()
119+
{
120+
return $this->urbanization;
121+
}
122+
123+
/**
124+
* @return string
125+
*/
126+
public function getBuildingName()
127+
{
128+
return $this->buildingName;
129+
}
130+
104131
/**
105132
* @return string
106133
*/
@@ -129,4 +156,16 @@ public function getPostalCodeWithExtension($divider = '-')
129156
{
130157
return $this->postcodePrimaryLow . $divider . $this->postcodeExtendedLow;
131158
}
159+
160+
/**
161+
* @return string
162+
*
163+
* @param int $lineNumber
164+
* @return string
165+
*/
166+
public function getAddressLine($lineNumber = 1)
167+
{
168+
$var = 'addressLine' . ($lineNumber > 1 ? $lineNumber : '');
169+
return $this->{$var};
170+
}
132171
}

0 commit comments

Comments
 (0)