-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathEcb.php
27 lines (26 loc) · 1.07 KB
/
Ecb.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
namespace Dfe\CurrencyConvert;
use Dfe\CurrencyConvert\Settings as S;
use Magento\Directory\Model\Currency\Import\AbstractImport;
class Ecb extends AbstractImport {
/**
* 2016-01-01
* 2022-12-24 We can not declare arguments types because they are undeclared in the overriden method.
* @override
* @see \Magento\Directory\Model\Currency\Import\AbstractImport::_convert()
* @used-by \Magento\Directory\Model\Currency\Import\AbstractImport::fetchRates()
* @param string $from
* @param string $to
*/
protected function _convert($from, $to):float {return df_float(dfa($this->rates($from), $to, 0.0));}
/**
* 2016-01-01
* @return array(string => float)
*/
private function rates(string $base):array {return dfc($this, function(string $base):array {return dfa(
# 2018-06-20
# We should use `http` (not `https`) to avoid the error:
# «Access Restricted - Your current Subscription Plan does not support HTTPS Encryption.»
df_http_json('http://data.fixer.io/api/latest', ['access_key' => S::s()->accessKey(), 'base' => $base]), 'rates', []
);}, [$base]);}
}