1 | <?php |
||
21 | class Exchange |
||
22 | { |
||
23 | /** |
||
24 | * The exchange rate service. |
||
25 | * @var \Swap\Swap |
||
26 | */ |
||
27 | private $service; |
||
28 | |||
29 | /** |
||
30 | * Constructor |
||
31 | * |
||
32 | * Accepts the name of an exchange rates service from Swap. Default is set to |
||
33 | * use Fixer. |
||
34 | * |
||
35 | * @param \Swap\Swap $service The service to query exchange rates from. |
||
36 | */ |
||
37 | 9 | public function __construct($service) |
|
41 | |||
42 | /** |
||
43 | * Add two \MoneyMan\Money objects together. This will return a new \MoneyMan\Money |
||
44 | * object. |
||
45 | * |
||
46 | * IMPORTANT! If the currencies are different, the second parameter will be converted |
||
47 | * to the first parameter's currency and then added together. |
||
48 | * |
||
49 | * @param \MoneyMan\Money $money1 The first money object. |
||
50 | * @param \MoneyMan\Money $money2 The second money object. |
||
51 | * |
||
52 | * @return \MoneyMan\Money |
||
53 | */ |
||
54 | 2 | public function add(Money $money1, Money $money2) |
|
62 | |||
63 | /** |
||
64 | * Subtract one \MoneyMan\Money object from another. This will return a brand new |
||
65 | * \MoneyMan\Money object. |
||
66 | * |
||
67 | * IMPORTANT! If the currencies are different, the second parameter will be converted |
||
68 | * to the first parameter's currency. Afterwards, the second parameter's exchanged |
||
69 | * amount will be deducted from the first parameter's amount and returned in a |
||
70 | * new \MoneyMan\Money object. |
||
71 | * |
||
72 | * @param \MoneyMan\Money $money1 The first money object |
||
73 | * @param \MoneyMan\Money $money2 The second money object |
||
74 | * |
||
75 | * @return \MoneyMan\Money |
||
76 | */ |
||
77 | 2 | public function subtract(Money $money1, Money $money2) |
|
85 | |||
86 | /** |
||
87 | * Exchanges one \MoneyMan\Money object into the desired currency. |
||
88 | * |
||
89 | * This should return a brand new \MoneyMan\Money object. |
||
90 | * |
||
91 | * @param \MoneyMan\Money $base The money we are exchanging. |
||
92 | * @param \MoneyMan\Currency $quote The currency we are exchanging to. |
||
93 | * |
||
94 | * @return \MoneyMan\Money |
||
95 | */ |
||
96 | 9 | public function exchange(Money $base, Currency $quote) |
|
108 | |||
109 | /** |
||
110 | * Gets the exchange rate between the base and quote currencies. |
||
111 | * |
||
112 | * @param Currency $base The currency we want to exchange from. |
||
113 | * @param Currency $quote The currency we want to exchange to. |
||
114 | * |
||
115 | * @return float |
||
116 | */ |
||
117 | 7 | public function getExchangeRate(Currency $base, Currency $quote) |
|
124 | } |
||
125 |