Skip to content

Commit 83390ab

Browse files
committed
add methods to world
1 parent db648a5 commit 83390ab

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/World.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,26 @@ public static function getCountriesFromJson()
4040
return json_decode(File::get(__DIR__ . '/../resources/json/countries.json'), true);
4141
}
4242

43+
public static function getCurrenciesFromJson()
44+
{
45+
return json_decode(File::get(__DIR__ . '/../resources/json/currencies.json'), true);
46+
}
47+
4348
public static function getCountryFromJson($country_code)
4449
{
4550
$countries = json_decode(File::get(__DIR__ . '/../resources/json/countries.json'), true);
46-
$result = array_values(Arr::where($countries, function ($value, $key) use ($country_code) {
51+
$result = array_values(Arr::where($countries, function ($value, $key) use ($country_code) {
4752
return $value['iso2'] === $country_code;
4853
}));
49-
return count($result) ? (object) $result[0] : null;
54+
return count($result) ? (object) $result[0] : null;
55+
}
56+
57+
public static function getCurrencyFromJson($currency_code)
58+
{
59+
$currencies = json_decode(File::get(__DIR__ . '/../resources/json/currencies.json'), true);
60+
$result = array_values(Arr::where($currencies, function ($value, $key) use ($currency_code) {
61+
return $value['code'] === $currency_code;
62+
}));
63+
return count($result) ? (object) $result[0] : null;
5064
}
5165
}

0 commit comments

Comments
 (0)