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

h4kuna / ares / 15383644655

30 May 2025 03:51PM UTC coverage: 83.105% (-1.8%) from 84.928%
15383644655

push

github

web-flow
Merge pull request #48 from h4kuna/update-phpstan

Update phpstan

15 of 42 new or added lines in 17 files covered. (35.71%)

364 of 438 relevant lines covered (83.11%)

0.83 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