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

h4kuna / ares / 15341626104

30 May 2025 07:28AM UTC coverage: 84.928% (+0.4%) from 84.524%
15341626104

push

github

h4kuna
fix(VIES): support for VAT number other countries

0 of 6 new or added lines in 2 files covered. (0.0%)

1 existing line in 1 file now uncovered.

355 of 418 relevant lines covered (84.93%)

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\Exceptions\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
        {
29
                $request = $this->transportProvider->createJsonRequest(static::$url . '/check-vat-number', $viesEntity->toParam());
×
30
                $response = $this->transportProvider->response($request);
×
31

32
                $data = $this->transportProvider->toJson($response);
×
NEW
33
                if (isset($data->errorWrappers[0]->error) && $data->errorWrappers[0] instanceof stdClass) {
×
NEW
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 */
42
                return $data;
×
43
        }
44

45

46
        public function status(): stdClass
47
        {
48
                $request = $this->transportProvider->createRequest(static::$url . '/check-status');
×
49
                $response = $this->transportProvider->response($request);
×
50

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