• 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

85.71
/src/Adis/Client.php
1
<?php declare(strict_types=1);
2

3
namespace h4kuna\Ares\Adis;
4

5
use h4kuna\Ares\Adis\Soap\Envelope;
6
use h4kuna\Ares\Exception\ServerResponseException;
7
use h4kuna\Ares\Http\TransportProvider;
8
use h4kuna\Ares\Tool\Arrays;
9
use h4kuna\Ares\Tool\Integer;
10
use h4kuna\Ares\Tool\Strings;
11
use h4kuna\Ares\Tool\Xml;
12
use SimpleXMLElement;
13
use stdClass;
14

15
final class Client
16
{
17
        public static string $url = 'https://adisrws.mfcr.cz/adistc/axis2/services/rozhraniCRPDPH.rozhraniCRPDPHSOAP';
18

19
        public function __construct(
1✔
20
                private TransportProvider $transportProvider,
21
        ) {
22
        }
1✔
23

24

25
        /**
26
         * @param array<string, string> $chunk
27
         * @return list<stdClass>
28
         *
29
         * @throws ServerResponseException
30
         */
31
        public function statusBusinessSubjects(array $chunk): array
1✔
32
        {
33
                $xml = Envelope::StatusNespolehlivySubjektRozsireny(...$chunk);
1✔
34
                $data = $this->request($xml, 'StatusNespolehlivySubjektRozsirenyResponse');
1✔
35
                $attributes = '@attributes';
1✔
36

37
                if (
38
                        $data->status instanceof stdClass === false
1✔
39
                        || isset($data->status->$attributes) === false
1✔
40
                        || $data->status->$attributes instanceof stdClass === false
1✔
41
                ) {
NEW
42
                        throw ServerResponseException::brokenXml();
×
43
                }
44
                $element = $data->status->$attributes;
1✔
45
                if ($element->statusCode !== '0') {
1✔
NEW
46
                        throw ServerResponseException::badResponse(Strings::fromMixedStrict($element->statusText), (int) Integer::fromMixed($element->statusCode));
×
47
                }
48

49
                return Arrays::fromStdClass($data->statusSubjektu);
1✔
50
        }
51

52
        /**
53
         * @throws ServerResponseException
54
         */
55
        private function request(string $xml, string $name): stdClass
1✔
56
        {
57
                $request = $this->transportProvider->createXmlRequest(self::$url, $xml);
1✔
58
                $response = $this->transportProvider->response($request);
1✔
59
                $xml = @simplexml_load_string($response->getBody()->getContents(), namespace_or_prefix: 'soapenv', is_prefix: true);
1✔
60

61
                if ($xml === false || ($xml->Body->children()->$name instanceof SimpleXMLElement) === false) {
1✔
NEW
62
                        throw ServerResponseException::badResponse(sprintf('Missing tag "%s" in response.', $name));
×
63
                }
64

65
                return Xml::toJson($xml->Body->children()->$name);
1✔
66
        }
67

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