macmotp / currencies
Curated list of currencies in PHP
v0.1.3
2024-10-09 09:02 UTC
Requires
- php: >=8.2
- illuminate/collections: >=10.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.21
- phpunit/phpunit: ^10.2
This package is auto-updated.
Last update: 2024-11-09 09:10:39 UTC
README
Library to Handle Currencies in PHP, simple and light
Useful for any ecommerce, fintech, or any app that requires 💰.
Requirements
- PHP >= 8.2
Installation
Install the package via composer:
composer require macmotp/currencies
This package is a main dependency for other 2 packages
Usage
Create Currency objects
use Macmotp\Currency; use Macmotp\Currencies\Support\CurrencyCode; use Macmotp\Currencies\Support\CurrencyName; // All Currencies adopt ISO 4217 standard $currencyCode = CurrencyCode::USD; // Create the object $currency = new Currency($currencyCode); // You can also input the code as string: $currency = new Currency('USD'); // Alternative methods: $currency = Currency::make($currencyCode); $currency = Currency::fromCode($currencyCode); echo $currency->toArray(); // [ // 'name' => 'United States Dollar', // 'code' => 'USD', // 'symbol' => '$', // 'flag' => 'us', // 'format' => [ // 'show_code' => false, // 'show_symbol' => true, // 'show_space' => false, // 'show_symbol_or_code_on_left' => true, // 'show_decimals' => true, // 'decimal_separator' => '.', // 'thousands_separator' => ',', // 'number_of_decimals' => 2, // 'subunit_level' => 2, // ], // ]
List of basic methods
getName()
: it returns the name;getCode()
: it returns the code;getSymbol()
: it returns the symbol;getFlag()
: it returns the flag (country code);getFormat()
: it returns the currency format;toArray()
: it converts the object into array;
List of Currencies in the package
use Macmotp\Currency; $list = Currency::all(); // This will return a Illuminate\Support\Collection
These are the implemented currencies:
AED
: United Arab Emirates DirhamAFN
: Afghan AfghaniALL
: Albanian LekAMD
: Armenian DramANG
: Netherlands Antillean GuilderAOA
: Angolan KwanzaARS
: Argentine PesoAUD
: Australian DollarAWG
: Aruban FlorinAZN
: Azerbaijani ManatBAM
: Bosnia and Herzegovina Convertible MarkBBD
: Barbados DollarBDT
: Bangladeshi TakaBGN
: Bulgarian LevBHD
: Bahraini DinarBIF
: Burundian FrancBMD
: Bermudian DollarBND
: Brunei DollarBOB
: Bolivian BolivianoBRL
: Brazilian RealBSD
: Bahamian DollarBTC
: BitcoinBTN
: Bhutanese NgultrumBWP
: Botswana PulaBYN
: Belarusian RubleBZD
: Belize DollarCAD
: Canadian DollarCDF
: Congolese FrancCHF
: Swiss FrancCLP
: Chilean PesoCNY
: Chinese Yuan - RenminbiCOP
: Colombian PesoCRC
: Costa Rican ColónCUP
: Cuban PesoCVE
: Cape Verdean EscudoCZK
: Czech KorunaDJF
: Djiboutian FrancDKK
: Danish KroneDOP
: Dominican PesoDZD
: Algerian DinarEGP
: Egyptian PoundERN
: Eritrean NakfaETB
: Ethiopian BirrEUR
: EuroFJD
: Fijian DollarFKP
: Falkland Islands PoundGBP
: British PoundGEL
: Georgian LariGHS
: Ghanaian CediGIP
: Gibraltar PoundGMD
: Gambian DalasiGNF
: Guinean FrancGTQ
: Guatemalan QuetzalGYD
: Guyanese DollarHKD
: Hong Kong DollarHNL
: Honduran LempiraHTG
: Haitian GourdeHUF
: Hungarian ForintIDR
: Indonesian RupiahILS
: Israeli New ShekelINR
: Indian RupeeIQD
: Iraqi DinarIRR
: Iranian RialISK
: Icelandic KrónaJMD
: Jamaican DollarJOD
: Jordanian DinarJPY
: Japanese YenKES
: Kenyan ShillingKGS
: Kyrgyz SomKHR
: Cambodian RielKMF
: Comorian FrancKPW
: North Korean WonKRW
: South Korean WonKWD
: Kuwaiti DinarKYD
: Cayman Islands DollarKZT
: Kazakhstani TengeLAK
: Lao KipLBP
: Lebanese PoundLKR
: Sri Lankan RupeeLRD
: Liberian DollarLSL
: Lesotho LotiLYD
: Libyan DinarMAD
: Moroccan DirhamMDL
: Moldovan LeuMGA
: Malagasy AriaryMKD
: Macedonian DenarMMK
: Burmese KyatMNT
: Mongolian TögrögMOP
: Macanese PatacaMRU
: Mauritanian OuguiyaMUR
: Mauritian RupeeMVR
: Maldivian RufiyaaMWK
: Malawian KwachaMXN
: Mexican PesoMYR
: Malaysian RinggitMZN
: Mozambican MeticalNAD
: Namibian DollarNGN
: Nigerian NairaNIO
: Nicaraguan CórdobaNOK
: Norwegian KroneNPR
: Nepalese RupeeNZD
: New Zealand DollarOMR
: Omani RialPAB
: Panamanian BalboaPEN
: Peruvian SolPGK
: Papua New Guinean KinaPHP
: Philippine PesoPKR
: Pakistani RupeePLN
: Polish ZłotyPYG
: Paraguayan GuaraníQAR
: Qatari RiyalRON
: Romanian LeuRSD
: Serbian DinarRUB
: Russian RubleRWF
: Rwandan FrancSAR
: Saudi RiyalSBD
: Solomon Islands DollarSCR
: Seychellois RupeeSDG
: Sudanese PoundSEK
: Swedish KronaSGD
: Singapore DollarSHP
: Saint Helena PoundSLE
: Sierra Leonean LeoneSOS
: Somali ShillingSRD
: Surinamese DollarSSP
: South Sudanese PoundSTN
: São Tomé and Príncipe DobraSYP
: Syrian PoundSZL
: Swazi LilangeniTHB
: Thai BahtTJS
: Tajikistani SomoniTMT
: Turkmenistani ManatTND
: Tunisian DinarTOP
: Tongan PaʻangaTRY
: Turkish LiraTTD
: Trinidad and Tobago DollarTWD
: New Taiwan DollarTZS
: Tanzanian ShillingUAH
: Ukrainian HryvniaUGX
: Ugandan ShillingUSD
: United States DollarUYU
: Uruguayan PesoUZS
: Uzbekistani SumVES
: Venezuelan Sovereign BolívarVND
: Vietnamese ĐồngVUV
: Vanuatu VatuWST
: Samoan TālāXAF
: Central African CFA FrancXCD
: Eastern Caribbean DollarXOF
: West African CFA FrancXPF
: CFP FrancYER
: Yemeni RialZAR
: South African RandZMW
: Zambian KwachaZWG
: Zimbabwe Gold
If you want to add another currency, please open an issue.
Testing
composer test
Changelog
Please see changelog for more information on what has changed recently.
Contributing
Please see contributing for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.