From cb82086b401779ab7a643afee811789a4b894247 Mon Sep 17 00:00:00 2001 From: Danny van Kooten Date: Mon, 9 Oct 2023 20:59:29 +0200 Subject: [PATCH] psr12 code style compliance --- phpcs.xml | 2 +- src/Clients/Client.php | 3 +-- src/Clients/IbericodeVatRatesClient.php | 5 +++-- src/Countries.php | 7 ++++--- src/Geolocation/GeolocatorInterface.php | 3 +-- src/Geolocation/IP2C.php | 3 +-- src/Geolocation/IP2Country.php | 2 +- src/Geolocator.php | 2 +- src/Period.php | 4 ++-- src/Rates.php | 8 ++++---- src/Validator.php | 12 ++++++------ src/Vies/Client.php | 6 +++--- src/Vies/ViesException.php | 1 - tests/Clients/ClientsTest.php | 1 - tests/RatesTest.php | 2 +- tests/ValidatorTest.php | 2 -- 16 files changed, 29 insertions(+), 34 deletions(-) diff --git a/phpcs.xml b/phpcs.xml index 7128fc3..968b85c 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -1,7 +1,7 @@ rules - + tests/ src/ diff --git a/src/Clients/Client.php b/src/Clients/Client.php index 8aa651d..10ab4b4 100644 --- a/src/Clients/Client.php +++ b/src/Clients/Client.php @@ -4,7 +4,6 @@ interface Client { - /** * This method should return an associative array in the following format: * @@ -18,5 +17,5 @@ interface Client * @return array * @throws ClientException */ - public function fetch() : array; + public function fetch(): array; } diff --git a/src/Clients/IbericodeVatRatesClient.php b/src/Clients/IbericodeVatRatesClient.php index 1f89d97..5247212 100644 --- a/src/Clients/IbericodeVatRatesClient.php +++ b/src/Clients/IbericodeVatRatesClient.php @@ -1,4 +1,5 @@ parseResponse($body); } - private function parseResponse(string $response_body) : array + private function parseResponse(string $response_body): array { $result = json_decode($response_body, false); diff --git a/src/Countries.php b/src/Countries.php index 56178a1..c89cf0f 100644 --- a/src/Countries.php +++ b/src/Countries.php @@ -1,4 +1,5 @@ offsetExists($code); } @@ -282,7 +283,7 @@ public function hasCountryCode(string $code) : bool /** * @return array */ - public function getCountryCodesInEU() : array + public function getCountryCodesInEU(): array { return ['AT', 'BE', 'BG', 'CY', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FI', 'FR', 'GR', 'HU', 'HR', 'IE', 'IT', 'LT', 'LU', 'LV', 'MT', 'NL', 'PL', 'PT', 'RO', 'SE', 'SI', 'SK']; } @@ -291,7 +292,7 @@ public function getCountryCodesInEU() : array * @param string $code * @return bool */ - public function isCountryCodeInEU(string $code) : bool + public function isCountryCodeInEU(string $code): bool { return in_array($code, $this->getCountryCodesInEU(), true); } diff --git a/src/Geolocation/GeolocatorInterface.php b/src/Geolocation/GeolocatorInterface.php index 744da20..9e5feeb 100644 --- a/src/Geolocation/GeolocatorInterface.php +++ b/src/Geolocation/GeolocatorInterface.php @@ -4,10 +4,9 @@ interface GeolocatorInterface { - /** * @param string $ipAddress The IP address to geolocate * @return string A ISO-3166-1-alpha2 country code or an empty string on failure */ - public function locateIpAddress(string $ipAddress) : string; + public function locateIpAddress(string $ipAddress): string; } diff --git a/src/Geolocation/IP2C.php b/src/Geolocation/IP2C.php index 2735747..5f60a6f 100644 --- a/src/Geolocation/IP2C.php +++ b/src/Geolocation/IP2C.php @@ -11,12 +11,11 @@ */ class IP2C implements GeolocatorInterface { - /** * @param string $ipAddress * @return string */ - public function locateIpAddress(string $ipAddress) : string + public function locateIpAddress(string $ipAddress): string { if ($ipAddress === '') { return ''; diff --git a/src/Geolocation/IP2Country.php b/src/Geolocation/IP2Country.php index f80057a..e9cc34c 100644 --- a/src/Geolocation/IP2Country.php +++ b/src/Geolocation/IP2Country.php @@ -15,7 +15,7 @@ class IP2Country implements GeolocatorInterface * @param string $ipAddress * @return string */ - public function locateIpAddress(string $ipAddress) : string + public function locateIpAddress(string $ipAddress): string { if ($ipAddress === '') { return ''; diff --git a/src/Geolocator.php b/src/Geolocator.php index 0c21012..188a61a 100644 --- a/src/Geolocator.php +++ b/src/Geolocator.php @@ -28,7 +28,7 @@ public function __construct(string $service = 'ip2c.org') $this->service = new $this->services[$service](); } - public function locateIpAddress(string $ipAddress) : string + public function locateIpAddress(string $ipAddress): string { if ($ipAddress === '') { return ''; diff --git a/src/Period.php b/src/Period.php index ee6579e..3b59d59 100644 --- a/src/Period.php +++ b/src/Period.php @@ -24,12 +24,12 @@ public function __construct(DateTimeInterface $effectiveFrom, array $rates) $this->rates = $rates; } - public function getEffectiveFrom() : DateTimeInterface + public function getEffectiveFrom(): DateTimeInterface { return $this->effectiveFrom; } - public function getRate(string $level) : float + public function getRate(string $level): float { if (!isset($this->rates[$level])) { throw new InvalidArgumentException("Invalid rate level: {$level}"); diff --git a/src/Rates.php b/src/Rates.php index cbbc3ce..21923ea 100644 --- a/src/Rates.php +++ b/src/Rates.php @@ -1,4 +1,5 @@ load(); @@ -135,7 +135,7 @@ private function resolvePeriod(string $countryCode, DateTimeInterface $datetime) * @return float * @throws \Exception */ - public function getRateForCountry(string $countryCode, string $level = self::RATE_STANDARD) : float + public function getRateForCountry(string $countryCode, string $level = self::RATE_STANDARD): float { $todayMidnight = new \DateTimeImmutable('today midnight'); return $this->getRateForCountryOnDate($countryCode, $todayMidnight, $level); @@ -148,7 +148,7 @@ public function getRateForCountry(string $countryCode, string $level = self::RAT * @return float * @throws Exception */ - public function getRateForCountryOnDate(string $countryCode, \DateTimeInterface $datetime, string $level = self::RATE_STANDARD) : float + public function getRateForCountryOnDate(string $countryCode, \DateTimeInterface $datetime, string $level = self::RATE_STANDARD): float { $activePeriod = $this->resolvePeriod($countryCode, $datetime); return $activePeriod->getRate($level); diff --git a/src/Validator.php b/src/Validator.php index bad9344..c7a92d0 100644 --- a/src/Validator.php +++ b/src/Validator.php @@ -1,11 +1,11 @@ validateVatNumberFormat($vatNumber) && $this->validateVatNumberExistence($vatNumber); } diff --git a/src/Vies/Client.php b/src/Vies/Client.php index be497b4..7104eec 100644 --- a/src/Vies/Client.php +++ b/src/Vies/Client.php @@ -1,4 +1,5 @@ getClient()->checkVat( @@ -61,7 +61,7 @@ public function checkVat(string $countryCode, string $vatNumber) : bool /** * @return SoapClient */ - protected function getClient() : SoapClient + protected function getClient(): SoapClient { if ($this->client === null) { $this->client = new SoapClient(self::URL, ['connection_timeout' => $this->timeout]); diff --git a/src/Vies/ViesException.php b/src/Vies/ViesException.php index fe6e29b..1bd63b0 100644 --- a/src/Vies/ViesException.php +++ b/src/Vies/ViesException.php @@ -6,5 +6,4 @@ class ViesException extends Exception { - } diff --git a/tests/Clients/ClientsTest.php b/tests/Clients/ClientsTest.php index 8009cdf..e3d2055 100644 --- a/tests/Clients/ClientsTest.php +++ b/tests/Clients/ClientsTest.php @@ -9,7 +9,6 @@ class ClientsTest extends TestCase { - /** * @group remote-http * @dataProvider clientProvider diff --git a/tests/RatesTest.php b/tests/RatesTest.php index 78b62f2..12e865b 100644 --- a/tests/RatesTest.php +++ b/tests/RatesTest.php @@ -12,7 +12,7 @@ class RatesTest extends TestCase { - protected function setUp() : void + protected function setUp(): void { if (file_exists('vendor/rates')) { unlink('vendor/rates'); diff --git a/tests/ValidatorTest.php b/tests/ValidatorTest.php index 895a81c..4941758 100644 --- a/tests/ValidatorTest.php +++ b/tests/ValidatorTest.php @@ -3,7 +3,6 @@ namespace Ibericode\Vat\Tests; use Ibericode\Vat\Validator; - use PHPUnit\Framework\TestCase; /** @@ -12,7 +11,6 @@ */ class ValidatorTest extends TestCase { - /** * @covers Validator::validateVatNumberFormat */