Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use of ::VIES_EXCLUDED_COUNTRY_CODES #143

Open
cottton opened this issue Jun 29, 2021 · 0 comments
Open

use of ::VIES_EXCLUDED_COUNTRY_CODES #143

cottton opened this issue Jun 29, 2021 · 0 comments

Comments

@cottton
Copy link
Contributor

cottton commented Jun 29, 2021

As i saw you added a new const VIES_EXCLUDED_COUNTRY_CODES to exclude f.e. country iso GB
(currently in master, not in last release) .

This const should be used to exclude f.e. GB in the listEuropeanCountries method and other places.

see https://github.com/DragonBe/vies/blob/master/src/Vies/Vies.php#L297

    if (! isset(self::VIES_EU_COUNTRY_LIST[$countryCode])) {
        throw new ViesException(sprintf('Invalid country code "%s" provided', $countryCode));
    }

see https://github.com/DragonBe/vies/blob/master/src/Vies/Vies.php#L339

        if (! isset(self::VIES_EU_COUNTRY_LIST[$requesterCountryCode])) {
            throw new ViesException(sprintf('Invalid requestor country code "%s" provided', $requesterCountryCode));
        }

see https://github.com/DragonBe/vies/blob/master/src/Vies/Vies.php#L339

    if (! isset(self::VIES_EU_COUNTRY_LIST[$countryCode])) {
        throw new ViesException(sprintf('Invalid country code "%s" provided', $countryCode));
    }

see https://github.com/DragonBe/vies/blob/master/src/Vies/Vies.php#L420

public static function listEuropeanCountries(): array
{
    static $list;

    if (! $list) {
        $list = array_combine(
            array_keys(self::VIES_EU_COUNTRY_LIST),
            array_column(self::VIES_EU_COUNTRY_LIST, 'name')
        );
        unset($list['EU']);
    }

    return $list;
}

The IMO best way would be a new method isEuropeanCountry(string $countryIso) : bool.
And in this new method we should return
is set at VIES_EU_COUNTRY_LIST
and is NOT set at VIES_EXCLUDED_COUNTRY_CODES

The exception thrown at https://github.com/DragonBe/vies/blob/master/src/Vies/Vies.php#L318
should be moved to https://github.com/DragonBe/vies/blob/master/src/Vies/Vies.php#L300
below the "Invalid country code" exception
to throw the "no longer supported" exception (which should actually be also say "invalid" IMO).

@cottton cottton changed the title ::listEuropeanCountries() should use ::VIES_EXCLUDED_COUNTRY_CODES use of ::VIES_EXCLUDED_COUNTRY_CODES Jun 30, 2021
jlsdohmen pushed a commit to jlsdohmen/vies that referenced this issue Jan 19, 2022
jlsdohmen added a commit to jlsdohmen/vies that referenced this issue Jan 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant