Skip to content

Commit 0d54288

Browse files
committed
Merge pull request gabrielbull#90 from stephenjwinn/patch-1
Set Address Line 2 and Address Line 3 in getValidatedAddress()
2 parents e39bcfa + c1da9bb commit 0d54288

File tree

1 file changed

+60
-3
lines changed

1 file changed

+60
-3
lines changed

src/Entity/AddressValidation/AVAddress.php

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ class AVAddress
1818
* @var string
1919
*/
2020
public $addressLine;
21+
/**
22+
* @var string
23+
*/
24+
public $addressLine2;
25+
/**
26+
* @var string
27+
*/
28+
public $addressLine3;
2129
/**
2230
* @var string
2331
*/
@@ -59,14 +67,19 @@ public function __construct(\SimpleXMLElement $xmlDoc)
5967
$this->addressClassification = isset($xmlDoc->AddressClassification) ? new AddressClassification($xmlDoc->AddressClassification) : null;
6068
$this->consigneeName = isset($xmlDoc->ConsigneeName) ? (string)$xmlDoc->ConsigneeName : '';
6169
$this->buildingName = isset($xmlDoc->BuildingName) ? (string)$xmlDoc->BuildingName : '';
62-
$this->addressLine = isset($xmlDoc->AddressLine) ? (string)$xmlDoc->AddressLine : '';
63-
$this->region = isset($xmlDoc->Region) ? (string)$xmlDoc->Regions : '';
70+
if (isset($xmlDoc->AddressLine)) {
71+
for ($i = 0, $len = count($xmlDoc->AddressLine); $i < $len; $i++) {
72+
$var = 'addressLine' . ($i > 0 ? $i + 1 : '');
73+
$this->{$var} = isset($xmlDoc->AddressLine[$i]) ? (string) $xmlDoc->AddressLine[$i] : '';
74+
}
75+
}
76+
$this->region = isset($xmlDoc->Region) ? (string)$xmlDoc->Region : '';
6477
$this->politicalDivision2 = isset($xmlDoc->PoliticalDivision2) ? (string)$xmlDoc->PoliticalDivision2 : '';
6578
$this->politicalDivision1 = isset($xmlDoc->PoliticalDivision1) ? (string)$xmlDoc->PoliticalDivision1 : '';
6679
$this->postcodePrimaryLow = isset($xmlDoc->PostcodePrimaryLow) ? (string)$xmlDoc->PostcodePrimaryLow : '';
6780
$this->postcodeExtendedLow = isset($xmlDoc->PostcodeExtendedLow) ? (string)$xmlDoc->PostcodeExtendedLow : '';
6881
$this->urbanization = isset($xmlDoc->Urbanization) ? (string)$xmlDoc->Urbanization : '';
69-
$this->consigneeName = isset($xmlDoc->CountryCode) ? (string)$xmlDoc->CountryCode : '';
82+
$this->countryCode = isset($xmlDoc->CountryCode) ? (string)$xmlDoc->CountryCode : '';
7083
}
7184

7285
/**
@@ -83,6 +96,38 @@ public function getCity()
8396
return $this->politicalDivision2;
8497
}
8598

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+
86131
/**
87132
* @return string
88133
*/
@@ -111,4 +156,16 @@ public function getPostalCodeWithExtension($divider = '-')
111156
{
112157
return $this->postcodePrimaryLow . $divider . $this->postcodeExtendedLow;
113158
}
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+
}
114171
}

0 commit comments

Comments
 (0)