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

h4kuna / ares / 15317728387

28 May 2025 11:06AM UTC coverage: 84.434% (-0.09%) from 84.524%
15317728387

push

github

h4kuna
feat(exceptions): rename namespace from plural exceptions to single expcetion

4 of 13 new or added lines in 8 files covered. (30.77%)

358 of 424 relevant lines covered (84.43%)

0.84 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
        public static function toJson(SimpleXMLElement|ResponseInterface $response): stdClass
1✔
15
        {
16
                if ($response instanceof ResponseInterface) {
1✔
17
                        $xml = @simplexml_load_string($response->getBody()->getContents());
1✔
18
                } else {
19
                        $xml = $response;
1✔
20
                }
21
                if ($xml === false) {
1✔
22
                        throw new ServerResponseException();
×
23
                }
24

25
                try {
26
                        $data = Json::decode(Json::encode($xml));
1✔
27
                        assert($data instanceof stdClass);
1✔
28
                } catch (JsonException $e) {
×
NEW
29
                        throw new ServerResponseException($e->getMessage(), (int) $e->getCode(), $e);
×
30
                }
31

32
                return $data;
1✔
33
        }
34

35
}
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