50 lines
1.6 KiB
PHP
50 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Money\Currency;
|
|
|
|
use App\Money\MoneyInterface;
|
|
use Brick\Money\Exception\CurrencyConversionException;
|
|
|
|
interface ExchangeInterface
|
|
{
|
|
/**
|
|
* @return string A short, unique, descriptive string of your exchange
|
|
*/
|
|
public function getName(): string;
|
|
|
|
/**
|
|
* @return int The heavier the weight, the less priority it will have
|
|
*/
|
|
public function getWeight(): int;
|
|
|
|
/**
|
|
* @param MoneyInterface $money The money to be converted
|
|
* @param string $toCurrency The currency to convert to
|
|
*
|
|
* @return MoneyInterface The converted MoneyInterface
|
|
*
|
|
* @throws CurrencyConversionException If the exchange rate is not available
|
|
*/
|
|
public function convert(MoneyInterface $money, string $toCurrency): MoneyInterface;
|
|
|
|
/**
|
|
* @param string $fromCurrency The currency to convert from
|
|
* @param string $toCurrency The currency to convert to
|
|
*
|
|
* @return float The rate of the conversion
|
|
*
|
|
* @throws CurrencyConversionException If the exchange rate is not available
|
|
*/
|
|
public function getConversionRate(string $fromCurrency, string $toCurrency): float;
|
|
|
|
/**
|
|
* @param string $fromCurrency The currency to convert from
|
|
* @param string $toCurrency The currency to convert to
|
|
*
|
|
* @return \DateTimeInterface The date and time at which the rate was last updated
|
|
*
|
|
* @throws CurrencyConversionException If the exchange rate is not available
|
|
*/
|
|
public function getConversionDate(string $fromCurrency, string $toCurrency): \DateTimeInterface;
|
|
}
|