Skip to content

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

Merged
merged 4 commits into from
Mar 1, 2016

Conversation

stephenjwinn
Copy link
Contributor

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.

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)) {
Copy link
Contributor

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] : '';

Copy link
Contributor Author

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.

@stefandoorn
Copy link
Contributor

Hi @stephenjwinn

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?

@stephenjwinn
Copy link
Contributor Author

Heyo @stefandoorn those changes are in. Should be a little better looking now. Let me know!

stefandoorn added a commit that referenced this pull request Mar 1, 2016
Set Address Line 2 and Address Line 3 in getValidatedAddress()
@stefandoorn stefandoorn merged commit 0d54288 into gabrielbull:master Mar 1, 2016
@stefandoorn
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants