1 | <?php |
||
11 | class Exchange implements \ArrayAccess, \IteratorAggregate |
||
12 | { |
||
13 | |||
14 | /** @var Caching\ICache */ |
||
15 | private $cache; |
||
16 | |||
17 | /** @var Currency\ListRates */ |
||
18 | private $listRates; |
||
19 | |||
20 | /** |
||
21 | * Default currency "from" input |
||
22 | * @var Currency\Property |
||
23 | */ |
||
24 | private $default; |
||
25 | |||
26 | /** |
||
27 | * Display currency "to" output |
||
28 | * @var Currency\Property |
||
29 | */ |
||
30 | private $output; |
||
31 | |||
32 | /** @var Currency\Property[] */ |
||
33 | private $tempRates; |
||
34 | |||
35 | public function __construct(Caching\ICache $cache) |
||
39 | |||
40 | /** @return Currency\Property */ |
||
41 | public function getDefault() |
||
48 | |||
49 | /** @return Currency\Property */ |
||
50 | public function getOutput() |
||
57 | |||
58 | /** |
||
59 | * Set default "from" currency. |
||
60 | * @param string $code |
||
61 | */ |
||
62 | public function setDefault($code) |
||
66 | |||
67 | /** |
||
68 | * @param Driver\ADriver|NULL $driver |
||
69 | * @param DateTime|NULL $date |
||
70 | * @return static |
||
71 | */ |
||
72 | public function setDriver(Driver\ADriver $driver = NULL, DateTime $date = NULL) |
||
86 | |||
87 | /** |
||
88 | * Set currency "to". |
||
89 | * @param string $code |
||
90 | * @return Currency\Property |
||
91 | */ |
||
92 | public function setOutput($code) |
||
96 | |||
97 | /** |
||
98 | * Transfer number by exchange rate. |
||
99 | * @param float|int|string $price number |
||
100 | * @param string|NULL |
||
101 | * @param string $to |
||
102 | * @return float|int |
||
103 | */ |
||
104 | public function change($price, $from = NULL, $to = NULL) |
||
108 | |||
109 | /** |
||
110 | * @param int|float $price |
||
111 | * @param string $from |
||
112 | * @param string $to |
||
113 | * @return array |
||
114 | */ |
||
115 | public function transfer($price, $from, $to) |
||
132 | |||
133 | /** |
||
134 | * Add history rate for rating |
||
135 | * @param string $code |
||
136 | * @param float $rate |
||
137 | * @return self |
||
138 | */ |
||
139 | public function addRate($code, $rate) |
||
145 | |||
146 | /** |
||
147 | * Remove history rating |
||
148 | * @param string $code |
||
149 | * @return self |
||
150 | */ |
||
151 | public function removeRate($code) |
||
157 | |||
158 | /** |
||
159 | * Load currency property. |
||
160 | * @param string|Currency\Property $index |
||
161 | * @return Currency\Property |
||
162 | */ |
||
163 | public function offsetGet($index) |
||
171 | |||
172 | public function offsetExists($offset) |
||
176 | |||
177 | public function offsetSet($offset, $value) |
||
181 | |||
182 | public function offsetUnset($offset) |
||
186 | |||
187 | public function getIterator() |
||
191 | |||
192 | /** |
||
193 | * @return Currency\ListRates |
||
194 | */ |
||
195 | protected function getListRates() |
||
202 | |||
203 | } |
||
204 |