pH-7 / eu-vat-validator

:moneybag: A simple and clean PHP library that validates EU VAT registration numbers against the central ec.europa.eu database (using the official europa API) :eu:
https://github.com/pH-7/eu-vat-validator
GNU General Public License v3.0
93 stars 17 forks source link

Remove starting / ending comma for getAddress() #2

Closed Noaber closed 6 years ago

Noaber commented 6 years ago

When requesting the address, it's starting / ending with a comma. Probably the $this->oResponse->address starts with a newline

Maybe add a trim or something in the removeNewLines

return trim(str_replace(["\n", "\r\n"], ', ', $sString), ', ');

pH-7 commented 6 years ago

Thanks for the suggestion @Noaber!

Do you mind to create a PR doing that? And run the phpunit test (update the test if necessary) once done

Probably, it will be better to create a new method or rename the existing method to something different like cleanAddress()

Thanks

pH-7 commented 6 years ago

BTW @Noaber What's the VAT number you used where you got commas?, so I can reproduce it (because in my case, I don't get commas).

Noaber commented 6 years ago

I will check it after my vacation 😉

pH-7 commented 6 years ago

Perfect @Noaber! I will keep it open then. Enjoy your vacation! 🌴😃

pH-7 commented 6 years ago

Hi again @Noaber How was your vacation? Did you have the chance to see with what VAT number you have seen the commas in the address?

Noaber commented 6 years ago

Hello @pH-7 ,

It was great! Will check on monday, back @ work then :)

pH-7 commented 6 years ago

👍 Beautiful! Thx!

Noaber commented 6 years ago

Took some more time then expected :) but I am trying with number NL004206034B01

$vat_validator = new Validator(new Europa, $vat_nr, 'NL');

This gives me , NIJVERHEIDSSTRAAT 00041, 7461AD RIJSSEN,

pH-7 commented 6 years ago

Thanks @Noaber! I can see it doesn't normally have commas, as officially shown at http://ec.europa.eu/taxation_customs/vies/ I will publish a patch for it.