Conditions | 5 |
Paths | 16 |
Total Lines | 24 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
17 | public static function decode(GetFullReportResponseRaw $fullReportResponseRaw): GetFullReportResponse |
||
18 | { |
||
19 | /** @var array<int, array<string, string>> $elements */ |
||
20 | $elements = []; |
||
21 | |||
22 | if ('' === $fullReportResponseRaw->getDanePobierzPelnyRaportResult()) { |
||
23 | return new GetFullReportResponse($elements); |
||
24 | } |
||
25 | |||
26 | try { |
||
27 | $xmlElementsResponse = new SimpleXMLElement($fullReportResponseRaw->getDanePobierzPelnyRaportResult()); |
||
28 | |||
29 | foreach ($xmlElementsResponse->dane as $resultData) { |
||
30 | /** @var array<string, string> $element */ |
||
31 | $element = []; |
||
32 | foreach ($resultData as $key => $item) { |
||
33 | $element[$key] = (string) $item; |
||
34 | } |
||
35 | $elements[] = $element; |
||
36 | } |
||
37 | |||
38 | return new GetFullReportResponse($elements); |
||
39 | } catch (\Exception $e) { |
||
40 | throw new InvalidServerResponseException('Invalid server response', 0, $e); |
||
41 | } |
||
44 |