Skip to content

Commit

Permalink
Fix #2 Some VAT's business addresses got commas
Browse files Browse the repository at this point in the history
  • Loading branch information
pH-7 committed Aug 22, 2018
1 parent fd0270b commit 6ba2b6c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/Vat/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function getName(): string

public function getAddress(): string
{
return $this->removeNewLines($this->oResponse->address) ?? '';
return $this->cleanAddress($this->oResponse->address) ?? '';
}

public function getRequestDate(): string
Expand All @@ -79,8 +79,8 @@ public function sanitize()
$this->sCountryCode = strtoupper($this->sCountryCode);
}

protected function removeNewLines(string $sString): string
protected function cleanAddress(string $sString): string
{
return str_replace(["\n", "\r\n"], ', ', $sString);
return trim(str_replace(["\n", "\r\n"], ', ', $sString), ', ');
}
}
2 changes: 1 addition & 1 deletion tests/Vat/ValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function testAddress(stdClass $oVatDetails)
{
$oValidator = $this->setUpAndMock($oVatDetails);
$this->assertEquals('ELSENSE STEENWEG 12, 1050 ELSENE', $oValidator->getAddress());
Phake::verify($oValidator)->removeNewLines('ELSENSE STEENWEG 12, 1050 ELSENE');
Phake::verify($oValidator)->cleanAddress('ELSENSE STEENWEG 12, 1050 ELSENE');
}

/**
Expand Down

0 comments on commit 6ba2b6c

Please sign in to comment.