Skip to content

Commit

Permalink
Switch to league/iso3166 (#94)
Browse files Browse the repository at this point in the history
  • Loading branch information
Propaganistas authored Sep 24, 2018
1 parent ff76518 commit bda366c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"illuminate/support": ">=5.0,<5.8",
"illuminate/validation": ">=5.0,<5.8",
"giggsey/libphonenumber-for-php": "^7.0|^8.0",
"julien-c/iso3166": "^2.0"
"league/iso3166": "^2.0"
},
"require-dev": {
"orchestra/testbench": "*",
Expand Down
12 changes: 10 additions & 2 deletions src/Traits/ParsesCountries.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php namespace Propaganistas\LaravelPhone\Traits;

use Illuminate\Support\Collection;
use Iso3166\Codes as ISO3166;
use League\ISO3166\ISO3166;

trait ParsesCountries
{
Expand All @@ -13,7 +13,15 @@ trait ParsesCountries
*/
public static function isValidCountryCode($country)
{
return ISO3166::isValid($country);
$iso3166 = new ISO3166;

try {
$iso3166->alpha2($country);

return true;
} catch (\Exception $e) {
return false;
}
}

/**
Expand Down

0 comments on commit bda366c

Please sign in to comment.