1 | <?php |
||
19 | class CurrencyExchangeService |
||
20 | { |
||
21 | /** |
||
22 | * @var CurrencyRatesService |
||
23 | */ |
||
24 | private $rates = null; |
||
25 | |||
26 | /** |
||
27 | * @var string |
||
28 | */ |
||
29 | private $defaultCurrency; |
||
30 | |||
31 | /** |
||
32 | * @param CurrencyRatesService $rates |
||
33 | * @param string $defaultCurrency |
||
34 | */ |
||
35 | 31 | public function __construct(CurrencyRatesService $rates, $defaultCurrency) |
|
40 | |||
41 | /** |
||
42 | * @param string $currency |
||
43 | * @param string|null $date |
||
44 | * |
||
45 | * @throws UndefinedCurrencyException |
||
46 | * |
||
47 | * @return float |
||
48 | 29 | */ |
|
49 | public function getCurrencyRate($currency, $date = null) |
||
59 | |||
60 | /** |
||
61 | * @return array|null |
||
62 | 1 | */ |
|
63 | public function getCurrencies() |
||
67 | |||
68 | /** |
||
69 | * This function calculate rates. |
||
70 | * |
||
71 | * @param float|int $amount |
||
72 | * @param string $toCurrency |
||
73 | * @param null $fromCurrency |
||
74 | * @param string|null $date |
||
75 | * |
||
76 | 28 | * @return float |
|
77 | */ |
||
78 | 28 | public function calculateRate($amount, $toCurrency, $fromCurrency = null, $date = null) |
|
94 | } |
||
95 |