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

h4kuna / ares / 15350576088

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

Pull #48

github

web-flow
Merge 2ba0d67e0 into 5e70d2b70
Pull Request #48: 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

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