Skip to content

Commit

Permalink
fix: split address overtoom
Browse files Browse the repository at this point in the history
  • Loading branch information
RichardPerdaan authored and EdieLemoine committed Nov 8, 2021
1 parent 6de7954 commit 4c34848
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
30 changes: 30 additions & 0 deletions Tests/SplitStreet/SplitStreetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,36 @@ public function testSplitStreet(
public function additionProvider()
{
return [
[
'carrier_id' => PostNLConsignment::CARRIER_ID,
'country' => 'NL',
'full_street_input' => 'overtoom 452-2',
'full_street' => 'overtoom 452 -2',
'street' => 'overtoom',
'number' => '452',
'number_suffix' => '-2',
'box_number' => null,
],
[
'carrier_id' => BpostConsignment::CARRIER_ID,
'country' => 'BE',
'full_street_input' => 'avenue roger lallemand 13 B13',
'full_street' => 'avenue roger lallemand 13 bus 13',
'street' => 'avenue roger lallemand',
'number' => '13',
'number_suffix' => null,
'box_number' => '13',
],
[
'carrier_id' => PostNLConsignment::CARRIER_ID,
'country' => 'BE',
'full_street_input' => 'avenue roger lallemand 13 B13',
'full_street' => 'avenue roger lallemand 13 bus 13',
'street' => 'avenue roger lallemand 13 bus 13',
'number' => null,
'number_suffix' => null,
'box_number' => null,
],
[
'carrier_id' => PostNLConsignment::CARRIER_ID,
'country' => 'NL',
Expand Down
2 changes: 1 addition & 1 deletion src/Helper/SplitStreet.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public static function splitStreet(string $fullStreet, string $local, string $de
$fullStreet = str_ireplace(self::BOX_SEPARATOR, self::BOX_NL, $fullStreet);
// When a caracter is present at BOX_SEPARATOR_BY_REGEX and followed by a number, it must replaced by bus
foreach (self::BOX_SEPARATOR_BY_REGEX as $boxRegex) {
$fullStreet = preg_replace('#' . $boxRegex . '([0-9])#', self::BOX_NL . '$1', $fullStreet);
$fullStreet = preg_replace('#' . $boxRegex . '([0-9])#', self::BOX_NL . ' ' . ltrim('$1'), $fullStreet);
}
}

Expand Down

0 comments on commit 4c34848

Please sign in to comment.