Skip to content
This repository has been archived by the owner on Jan 17, 2024. It is now read-only.

Commit

Permalink
Parse CD and CO parameters from CA (#53)
Browse files Browse the repository at this point in the history
* Parse CD and CO parameters from CA

Some responses don't contain CD and CO parameters, but can be parsed from the CA parameter. Example:
<D:AA zdroj="ARES">
<D:IDA>210870551</D:IDA>
<D:KS>203</D:KS>
<D:NS>Česká republika</D:NS>
<D:N>Praha 6</D:N>
<D:NCO>Břevnov</D:NCO>
<D:NU>U třetí baterie</D:NU>
<D:CA>1056/5</D:CA>
<D:PSC>16200</D:PSC>
<D:AU> </D:AU>
</D:AA>

* Use null coalescing for CO field
* Add MapperTest
* Set limit to explode('/', CA)

---------

Co-authored-by: Jan Trejbal <jan@trejbal.land>
  • Loading branch information
LuKo and trejjam committed Apr 5, 2023
1 parent 69ac45c commit 7f6d462
Show file tree
Hide file tree
Showing 2 changed files with 480 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Mapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ private function mapToEntity(SimpleXMLElement $VBAS) : Entity\Ares
);

$AA = $VBAS->AA;

if (isset($AA->CA) && !isset($AA->CD) && !isset($AA->CO)) {
$ca = explode('/', strval($AA->CA), 2);
$AA->CD = $ca[0];
$AA->CO = $ca[1] ?? '';
}

$address = new Entity\Address(
intval($AA->IDA),
intval($AA->KS),
Expand Down
Loading

0 comments on commit 7f6d462

Please sign in to comment.