Skip to content

Commit

Permalink
Merge pull request #5 from answear/skip-unknown-services
Browse files Browse the repository at this point in the history
Skip unknown services
  • Loading branch information
malarzm authored May 4, 2021
2 parents bb295d5 + 13cd2e6 commit 125b886
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/Service/PUDOFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ private function createAdditionalInfo(\SimpleXMLElement $xml): AdditionalInfo
{
$info = new AdditionalInfo();
foreach (explode(';', (string) $xml->SERVICE_PUDO) as $service) {
$info->services[] = Service::byValue($service);
try {
$info->services[] = Service::byValue($service);
} catch (\InvalidArgumentException $e) {
// NOP, do not fail hard for new services
}
}
$info->wheelchairAccessible = 'true' === (string) $xml->HANDICAPE;
$info->parking = 'true' === (string) $xml->PARKING;
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/full_pudo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<PUDO_ID>PL15625</PUDO_ID>
<ORDER>1</ORDER>
<PUDO_TYPE>100</PUDO_TYPE>
<SERVICE_PUDO>100;200;201</SERVICE_PUDO>
<SERVICE_PUDO>100;200;201;THIS_DOES_NOT_EXIST</SERVICE_PUDO>
<LANGUAGE>PL</LANGUAGE>
<ADDRESS1>Na Szaniec 21 box 4</ADDRESS1>
<ADDRESS2>ADDRESS2</ADDRESS2>
Expand Down

0 comments on commit 125b886

Please sign in to comment.