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

h4kuna / ares / 20388943717

05 Dec 2025 08:01AM UTC coverage: 84.821% (-4.7%) from 89.497%
20388943717

push

github

h4kuna
Update ARES API 1.3.0

17 of 18 new or added lines in 1 file covered. (94.44%)

21 existing lines in 5 files now uncovered.

380 of 448 relevant lines covered (84.82%)

0.85 hits per line

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

15.38
/src/Vies/Client.php
1
<?php declare(strict_types=1);
2

3
namespace h4kuna\Ares\Vies;
4

5
use h4kuna\Ares\Exception\ServerResponseException;
6
use h4kuna\Ares\Http\TransportProvider;
7
use stdClass;
8

9
/**
10
 * @phpstan-type ViesResponse object{countryCode: string, vatNumber: string, requestDate: string, valid: bool, requestIdentifier: string, name: string, address: string, traderName: string, traderStreet: string, traderPostalCode: string, traderCity: string, traderCompanyType: string, traderNameMatch: string, traderStreetMatch: string, traderPostalCodeMatch: string, traderCityMatch: string, traderCompanyTypeMatch: string}&\stdClass
11
 */
12
final class Client
13
{
14
        public static string $url = 'https://ec.europa.eu/taxation_customs/vies/rest-api';
15

16

17
        public function __construct(private TransportProvider $transportProvider)
1✔
18
        {
19
        }
1✔
20

21

22
        /**
23
         * @return ViesResponse
24
         *
25
         * @throws ServerResponseException
26
         */
27
        public function checkVatNumber(ViesEntity $viesEntity): object
28
        {
UNCOV
29
                $request = $this->transportProvider->createJsonRequest(static::$url . '/check-vat-number', $viesEntity->toParam());
×
UNCOV
30
                $response = $this->transportProvider->response($request);
×
31

UNCOV
32
                $data = $this->transportProvider->toJson($response);
×
UNCOV
33
                if (isset($data->errorWrappers[0]->error) && $data->errorWrappers[0] instanceof stdClass) {
×
UNCOV
34
                        if (isset($data->errorWrappers[0]->message)) {
×
UNCOV
35
                                throw new ServerResponseException(sprintf('%s: %s', $data->errorWrappers[0]->error, $data->errorWrappers[0]->message));
×
36
                        }
37

38
                        throw new ServerResponseException($data->errorWrappers[0]->error);
×
39
                }
40

41
                /** @var ViesResponse $data */
UNCOV
42
                return $data;
×
43
        }
44

45
        /**
46
         * @throws ServerResponseException
47
         */
48
        public function status(): stdClass
49
        {
UNCOV
50
                $request = $this->transportProvider->createRequest(static::$url . '/check-status');
×
UNCOV
51
                $response = $this->transportProvider->response($request);
×
52

UNCOV
53
                return $this->transportProvider->toJson($response);
×
54
        }
55
}
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

© 2025 Coveralls, Inc