Skip to content

indibeast/currency-format

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Currency Formatter

Build Status Coverage Status Code Climate Total Downloads Latest Unstable Version License

Minimum Requirements

  • PHP 5.5+

Installation

Install using composer:

composer require indibeast/currency-formatter

Example

 $price = new Currency\Price(3000,'LKR');
 $price->pretty();// Rs 3,000.00

You can pass the options as an array to the third parameter.

 $price = new Currency\Price(3000,'LKR',['show_decimal' => false,'seperator' => ',']);
 $price->pretty();// Rs 3,000

Currency conversion

 $currency = new Price(1,'USD');
 $currency->setConverter(new OpenExchangeConverter('app_id'));// Pass true as second parameter if you are having an enterprise APP_ID.
 $currency->convert('LKR') // This will convert U.S Dollars to Sri Lankan Rupees

If you wish to implement your own currency exchange provider implement \Currency\Converter\ConverterInterface

 class FixedConverter implements ConverterInterface{

    /**
     * @return float
     */
    public function getConversionRate($code,$to)
    {
        return 1;
    }
 }

License

The MIT License (MIT). Please see License File for more information.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages