From 5a87e82d5e643434d44ce13a1c69f2ff2e749eb1 Mon Sep 17 00:00:00 2001 From: Jasper Zonneveld Date: Thu, 14 Mar 2024 10:21:46 +0100 Subject: [PATCH] feat: cleanup URLs --- src/Api/Situations.php | 4 +++- src/Parsers/SituationParser.php | 5 +++-- src/Parsers/UrlParser.php | 27 +++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 src/Parsers/UrlParser.php diff --git a/src/Api/Situations.php b/src/Api/Situations.php index 42cc977..463aaeb 100644 --- a/src/Api/Situations.php +++ b/src/Api/Situations.php @@ -12,6 +12,7 @@ use Swis\Melvin\Parsers\PeriodParser; use Swis\Melvin\Parsers\RestrictionParser; use Swis\Melvin\Parsers\SituationParser; +use Swis\Melvin\Parsers\UrlParser; use Swis\Melvin\SituationFilterParameters; class Situations extends AbstractApi @@ -29,7 +30,8 @@ public function __construct(Client $client, ?SituationParser $situationParser = new AttachmentParser(), new RestrictionParser($geometryParser), new DetourParser($geometryParser), - new ContactParser() + new ContactParser(), + new UrlParser() ); } diff --git a/src/Parsers/SituationParser.php b/src/Parsers/SituationParser.php index ab33ddf..5a65dbf 100644 --- a/src/Parsers/SituationParser.php +++ b/src/Parsers/SituationParser.php @@ -28,7 +28,8 @@ public function __construct( protected AttachmentParser $attachmentParser, protected RestrictionParser $restrictionParser, protected DetourParser $detourParser, - protected ContactParser $contactParser + protected ContactParser $contactParser, + protected UrlParser $urlParser ) { } @@ -91,7 +92,7 @@ public function parse(\stdClass $object, array $restrictions, array $detours = [ $object->properties->project, Source::from($object->properties->source), $object->properties->published, - ($object->properties->url ?? '') ?: null, + $this->urlParser->parse($object->properties->url ?? ''), ($object->properties->urlDescription ?? '') ?: null, Delay::from($object->properties->delay), ($object->properties->workType ?? '') ? WorkType::from($object->properties->workType) : null, diff --git a/src/Parsers/UrlParser.php b/src/Parsers/UrlParser.php new file mode 100644 index 0000000..0ea69e0 --- /dev/null +++ b/src/Parsers/UrlParser.php @@ -0,0 +1,27 @@ +