Package Data | |
---|---|
Maintainer Username: | ionut |
Maintainer Contact: | office@ionut-bajescu.com (Ionut Bajescu) |
Package Create Date: | 2016-01-30 |
Package Last Update: | 2016-04-15 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2025-04-28 15:07:18 |
Package Statistics | |
---|---|
Total Downloads: | 3,379 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 6 |
Total Watchers: | 2 |
Total Forks: | 0 |
Total Open Issues: | 0 |
Currency is a currency exchanger written in PHP that aims for ease of use and complete independence of any frameworks or CMSs.
Besides being fully unit-tested and well written, it is also one of the few libraries(if not the only) that uses the European Central Bank rates. This does not only mean that you get the conversion rates for free but also that you do not tie one of the core responsibilities of your application to a fragile third-party service.
So far, it provides an out of the box service provider for Laravel. But besides that, the library is completely framework agnostic and it'll stay like this for the foreseeable future.
Some applications do not need the complexity and verbosity of our OOP endeavours. For those, currency has a clean helper that would love to help you keep your code short.
Let's say you want to convert $20.5 to EUR by using the latest rates provided by the European Central Bank, the code accomplishing that will look like this:
$eurAmount = currency(20.5, 'USD')->toEUR();
In case you don't fancy having helpers in your codebase you'll be happy to know that using the helper function is optional. Let's just rewrite the previous example and get rid of the helper:
$exchanger = (new Ionut\Currency\Factory)->create();
$usdAmount = new Amount(20.5, 'USD');
$eurAmount = $exchanger->convert($usdAmount, 'EUR');
Of course, there's more code to write by using this approach. But such level of control couldn't be readily accomplished by using the helper function.
As seen in the previous example, there are three distinct parts which form the core of the Currency library:
By remembering those and keeping in mind that the library fully follows the interfaces found in the Contracts
namespace, you should be able to master everything there is to know about this library.
Because libraries die more often that one would expect, Currency provides the developer with Contracts for every of the Currency's class, allowing his code to remain SOLID while using the best currency conversion library there is.
The present library is fully unit-tested, contributors are welcome to check the aforementioned tests in the tests
folder and run them by calling PHPUnit.
The present package is open-sourced software licensed under the MIT license.