-
Notifications
You must be signed in to change notification settings - Fork 259
Set Address Line 2 and Address Line 3 in getValidatedAddress() #90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The second and third address lines are received from UPS, but not passed back in the getValidatedAddress() method. CountryCode was being assigned to the consigneeName prop, and Region had a typo in the assignment.
Style changes.
@@ -59,14 +67,24 @@ public function __construct(\SimpleXMLElement $xmlDoc) | |||
$this->addressClassification = isset($xmlDoc->AddressClassification) ? new AddressClassification($xmlDoc->AddressClassification) : null; | |||
$this->consigneeName = isset($xmlDoc->ConsigneeName) ? (string)$xmlDoc->ConsigneeName : ''; | |||
$this->buildingName = isset($xmlDoc->BuildingName) ? (string)$xmlDoc->BuildingName : ''; | |||
$this->addressLine = isset($xmlDoc->AddressLine) ? (string)$xmlDoc->AddressLine : ''; | |||
$this->region = isset($xmlDoc->Region) ? (string)$xmlDoc->Regions : ''; | |||
if (isset($xmlDoc->AddressLine)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we refactor this a bit? It feels a bit double for me.
I would say something like this will also do:
$var = 'addressLine' . ($i > 0 ? $i + 1 : '');
$this->{$var} = isset($xmlDoc->AddressLine[$i]) ? (string) $xmlDoc->AddressLine[$i] : '';
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's definitely not the sexiest 8 lines of code I've ever written. I appreciate your solution--quite a bit more elegant. I'll swap it out.
Thanks! I made one comment in the code. Besides that, we might need some getter functions in there to get the data without accessing properties. Could you insert these too? |
Heyo @stefandoorn those changes are in. Should be a little better looking now. Let me know! |
Set Address Line 2 and Address Line 3 in getValidatedAddress()
Even though it's merged, it would be great to add unit tests for the new functionality. It doesn't break things, but it's mainly for the future. |
The second and third address lines are received from UPS, but not passed back in the getValidatedAddress() method. CountryCode was being assigned to the consigneeName prop, and Region had a typo in the assignment.