1 | <?php |
||
23 | class OpenExchangeRatesService |
||
24 | { |
||
25 | /** |
||
26 | * @var string |
||
27 | * |
||
28 | * the app id |
||
29 | */ |
||
30 | protected $appId; |
||
31 | |||
32 | /** |
||
33 | * @var string |
||
34 | * |
||
35 | * the api endpoint |
||
36 | */ |
||
37 | protected $endPoint = '://openexchangerates.org/api'; |
||
38 | |||
39 | /** |
||
40 | * @var string |
||
41 | * |
||
42 | * base currency |
||
43 | */ |
||
44 | protected $baseCurrency = ''; |
||
45 | |||
46 | /** |
||
47 | * @var ClientInterface |
||
48 | */ |
||
49 | protected $client; |
||
50 | |||
51 | /** |
||
52 | * @var bool |
||
53 | * |
||
54 | * https is used |
||
55 | */ |
||
56 | protected $https; |
||
57 | |||
58 | /** |
||
59 | * Service constructor |
||
60 | * |
||
61 | * @param string $openExchangeRatesAppId the app_id for OpenExchangeRates |
||
62 | * @param array $apiOptions Options for the OpenExchangeRatesApi |
||
63 | * @param object $client Http client for requests |
||
64 | * @throws \ErrorException |
||
65 | */ |
||
66 | public function __construct($openExchangeRatesAppId, $apiOptions, $client) |
||
73 | |||
74 | /** |
||
75 | * @param $client |
||
76 | * @return HttpClientInterface |
||
77 | * @throws \ErrorException |
||
78 | */ |
||
79 | private function wrapClient($client) |
||
90 | |||
91 | /** |
||
92 | * @return string |
||
93 | */ |
||
94 | public function getEndPoint() |
||
103 | |||
104 | /** |
||
105 | * Get the appId |
||
106 | * |
||
107 | * @return string |
||
108 | */ |
||
109 | public function getAppId() |
||
113 | |||
114 | /** |
||
115 | * Get if https is enabled |
||
116 | * |
||
117 | * @return boolean |
||
118 | */ |
||
119 | public function useHttps() |
||
123 | |||
124 | /** |
||
125 | * Sets whether to use https |
||
126 | * |
||
127 | * @param boolean $https |
||
128 | */ |
||
129 | public function setHttps($https) |
||
133 | |||
134 | /** |
||
135 | * Get the base currency |
||
136 | * |
||
137 | * @return string |
||
138 | */ |
||
139 | public function getBaseCurrency() |
||
143 | |||
144 | /** |
||
145 | * Set the base currency |
||
146 | * |
||
147 | * @param string $baseCurrency |
||
148 | */ |
||
149 | public function setBaseCurrency($baseCurrency) |
||
153 | |||
154 | |||
155 | /** |
||
156 | * Converts $value from currency $symbolFrom to currency $symbolTo |
||
157 | * |
||
158 | * @param float $value value to convert |
||
159 | * @param string $symbolFrom symbol to convert from |
||
160 | * @param string $symbolTo symbol to convert to |
||
161 | * |
||
162 | * @return float |
||
163 | */ |
||
164 | public function convertCurrency($value, $symbolFrom, $symbolTo) |
||
174 | |||
175 | /** |
||
176 | * If base currency is overridden, return $baseCurrency, otherwise |
||
177 | * return the object's base currency |
||
178 | * |
||
179 | * @param $baseCurrency |
||
180 | * |
||
181 | * @return string |
||
182 | */ |
||
183 | protected function prepareBaseCurrency($baseCurrency) |
||
187 | |||
188 | /** |
||
189 | * Given a query and symbols, puts them in the query or not |
||
190 | * |
||
191 | * @param $query |
||
192 | * @param $symbols |
||
193 | * |
||
194 | * @return mixed |
||
195 | */ |
||
196 | protected function prepareSymbols($query, $symbols) |
||
204 | |||
205 | /** |
||
206 | * Get the latest exchange rates |
||
207 | * |
||
208 | * @param array $symbols array of currency codes to get the rates for. |
||
209 | * Default empty (all currencies) |
||
210 | * @param string $base Base currency, default NULL (gets it from config) |
||
211 | * |
||
212 | * @return array |
||
213 | */ |
||
214 | public function getLatest(array $symbols = array(), $base = null) |
||
227 | |||
228 | |||
229 | /** |
||
230 | * Gets a list of all available currencies |
||
231 | */ |
||
232 | public function getCurrencies() |
||
240 | |||
241 | |||
242 | /** |
||
243 | * Format response |
||
244 | * |
||
245 | * @param $method String |
||
246 | * @param $uri String |
||
247 | * @param $options array |
||
248 | * |
||
249 | * @return array |
||
250 | * @internal param HttpResponseInterface $response |
||
251 | * |
||
252 | */ |
||
253 | private function getResponse($method, $uri, $options) |
||
262 | |||
263 | |||
264 | /** |
||
265 | * Get historical data |
||
266 | * |
||
267 | * @param \DateTime $date |
||
268 | * |
||
269 | * @return array |
||
270 | */ |
||
271 | public function getHistorical(DateTime $date) |
||
284 | } |
||
285 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..