File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1616 "ext-curl" : " *" ,
1717 "illuminate/cache" : " ^12.0 || ^13.0" ,
1818 "illuminate/console" : " ^12.0 || ^13.0" ,
19- "illuminate/support" : " ^12.0 || ^13.0"
19+ "illuminate/support" : " ^12.0 || ^13.0" ,
20+ "league/iso3166" : " ^4.0"
2021 },
2122 "require-dev" : {
2223 "friendsofphp/php-cs-fixer" : " ^3.50" ,
Original file line number Diff line number Diff line change 66
77use Illuminate \Support \Arr ;
88use Illuminate \Cache \CacheManager ;
9+ use League \ISO3166 \Exception \OutOfBoundsException ;
10+ use League \ISO3166 \ISO3166 ;
911
1012/**
1113 * @psalm-import-type LocationArray from \InteractionDesignFoundation\GeoIP\Location
@@ -19,12 +21,7 @@ class GeoIP
1921 */
2022 protected $ location = null ;
2123
22- /**
23- * Currency data.
24- *
25- * @var array<string, string>|null
26- */
27- protected $ currencies = null ;
24+ protected ?ISO3166 $ iso3166 = null ;
2825
2926 /**
3027 * GeoIP service instance.
@@ -162,11 +159,18 @@ private function find(?string $ip = null): Location
162159 */
163160 public function getCurrency ($ iso )
164161 {
165- if ($ this -> currencies === null && $ this ->config ('include_currency ' , false )) {
166- $ this -> currencies = include ( __DIR__ . ' /Support/Currencies.php ' ) ;
162+ if (! $ this ->config ('include_currency ' , false )) {
163+ return null ;
167164 }
168165
169- return Arr::get ($ this ->currencies , $ iso );
166+ try {
167+ $ this ->iso3166 ??= new ISO3166 ();
168+ $ country = $ this ->iso3166 ->alpha2 ($ iso );
169+
170+ return $ country ['currency ' ][0 ] ?? null ;
171+ } catch (OutOfBoundsException ) {
172+ return null ;
173+ }
170174 }
171175
172176 /**
Load diff This file was deleted.
You can’t perform that action at this time.
0 commit comments