• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

h4kuna / ares / 15350555273

30 May 2025 03:48PM UTC coverage: 87.919%. First build
15350555273

push

github

h4kuna
feat(composer): update phpstan

14 of 36 new or added lines in 13 files covered. (38.89%)

393 of 447 relevant lines covered (87.92%)

0.88 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

72.73
/src/Tool/Xml.php
1
<?php declare(strict_types=1);
2

3
namespace h4kuna\Ares\Tool;
4

5
use h4kuna\Ares\Exception\ServerResponseException;
6
use JsonException;
7
use Nette\Utils\Json;
8
use Psr\Http\Message\ResponseInterface;
9
use SimpleXMLElement;
10
use stdClass;
11

12
final class Xml
13
{
14
        /**
15
         * @throws ServerResponseException
16
         */
17
        public static function toJson(SimpleXMLElement|ResponseInterface $response): stdClass
1✔
18
        {
19
                if ($response instanceof ResponseInterface) {
1✔
20
                        $xml = @simplexml_load_string($response->getBody()->getContents());
1✔
21
                } else {
22
                        $xml = $response;
1✔
23
                }
24
                if ($xml === false) {
1✔
NEW
25
                        throw ServerResponseException::brokenXml();
×
26
                }
27

28
                try {
29
                        $data = Json::decode(Json::encode($xml));
1✔
30
                        assert($data instanceof stdClass);
1✔
31
                } catch (JsonException $e) {
×
NEW
32
                        throw ServerResponseException::fromException($e);
×
33
                }
34

35
                return $data;
1✔
36
        }
37

38
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc