PHP code example of brightcreations / money-converter
1. Go to this page and download the library: Download brightcreations/money-converter library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
brightcreations / money-converter example snippets
use BrightCreations\MoneyConverter\Contracts\MoneyConverterInterface;
// Converts 100.00 USD to EUR using the current exchange rate
$convertedMinorInt = $service->convert(10000, 'USD', 'EUR');
// Converts 100.00 USD to EUR using the exchange rate of a previous date
$convertedMinorInt = $service->convert(10000, 'USD', 'EUR', now()->subDays(1));
use BrightCreations\MoneyConverter\Contracts\MoneyConverterInterface;
class SomeClass {
private $service;
public function __construct(MoneyConverterInterface $service) {
$this->service = $service;
}
public function someMethod() {
$convertedMinorInt = $this->service->convert(10000, 'USD', 'EUR');
}
}
use BrightCreations\MoneyConverter\Contracts\MoneyConverterInterface;
$service = resolve(MoneyConverterInterface::class);
$convertedMinorInt = $service->convert(10000, 'USD', 'EUR');
use BrightCreations\MoneyConverter\Contracts\MoneyConverterInterface;
$service = app()->make(MoneyConverterInterface::class);
$convertedMinorInt = $service->convert(10000, 'USD', 'EUR');