Ratings | | Unique User Downloads | | Download Rankings |
Not enough user ratings | | Total: 158 This week: 1 | | All time: 8,941 This week: 257 |
|
Description | | Author terdia
Contributor
|
This class can get the symbol of any given currency.
It can take as parameter of code of a given currency.
The class can return the symbol associated to that currency. Innovation Award
 September 2019
Number 12 |
Each currency used in different countries to represent money has a symbol that is associated the currency which is used to make clear when a given money amount is displayed so other people can see prices or other values that represent money.
This class can return the symbols used to represent many currencies using pure PHP, thus not relying on the availability of any PHP extension for that purpose.
Manuel Lemos |
| |
 |
|
Innovation award
 Nominee: 4x |
|
Details
php currency-util
A simple library to lookup the currency symbol for a given currency code.
Installation
composer req terdia/currency-util
Usage
Get symbol from currency code
use Currency\Util\CurrencySymbolUtil;
CurrencySymbolUtil::getSymbol('GBP') //=> '£'
CurrencySymbolUtil::getSymbol('EUR') //=> '?'
CurrencySymbolUtil::getSymbol('USD') //=> '$'
CurrencySymbolUtil::getSymbol('NOT A VALID CODE') throw InvalidArgumentException
Get List of supported currency code
use Currency\Util\CurrencySymbolMapping;
var_dump(CurrencySymbolMapping::values())
// =>
[
"USD" => "$",
"GBP" => "£",
"EUR" => "?",
?
]
Tests
vendor/bin/phpunit tests
Contribution
Feel free to contribute to this library.
|
Applications that use this package |
|
No pages of applications that use this class were specified.
If you know an application of this package, send a message to the author to add a link here.