1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* This file is part of the Exchange Rate package, an RunOpenCode project. |
4
|
|
|
* |
5
|
|
|
* Implementation of exchange rate crawler for Banca Intesa Serbia, http://www.bancaintesa.rs. |
6
|
|
|
* |
7
|
|
|
* (c) 2017 RunOpenCode |
8
|
|
|
* |
9
|
|
|
* For the full copyright and license information, please view the LICENSE |
10
|
|
|
* file that was distributed with this source code. |
11
|
|
|
*/ |
12
|
|
|
namespace RunOpenCode\ExchangeRate\BancaIntesaSerbia; |
13
|
|
|
|
14
|
|
|
use RunOpenCode\ExchangeRate\BancaIntesaSerbia\Enum\RateType; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Class Api |
18
|
|
|
* |
19
|
|
|
* Api definition of Banca Intesa Serbia crawler. |
20
|
|
|
* |
21
|
|
|
* @package RunOpenCode\ExchangeRate\BancaIntesaSerbia |
22
|
|
|
*/ |
23
|
|
|
final class Api |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* Unique name of source. |
27
|
|
|
*/ |
28
|
|
|
const NAME = 'banca_intesa_serbia'; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Supported rate types and currency codes by Banca Intesa Serbia. |
32
|
|
|
* |
33
|
|
|
* NOTE: Banca Intesa Serbia still publishes rates of some of the obsolete currencies. |
34
|
|
|
* |
35
|
|
|
* @var array |
36
|
|
|
*/ |
37
|
|
|
private static $supports = array( |
38
|
|
|
RateType::MEDIAN => array('EUR', 'AUD', 'ATS', 'BEF', 'CAD', 'CNY', 'HRK', 'CZK', 'DKK', 'FIM', 'FRF', 'DEM', 'GRD', |
39
|
|
|
'HUF', 'IEP', 'ITL', 'JPY', 'KWD', 'LUF', 'NOK', 'PTE', 'RUB', 'SKK', 'ESP', 'SEK', 'CHF', |
40
|
|
|
'GBP', 'USD', 'BAM', 'PLN'), |
41
|
|
|
RateType::FOREIGN_CASH_BUYING => array('EUR', 'AUD', 'CAD', 'HRK', 'CZK', 'DKK', 'HUF', 'JPY', 'NOK', 'RUB', 'SEK', |
42
|
|
|
'CHF', 'GBP', 'USD', 'BAM', 'PLN'), |
43
|
|
|
RateType::FOREIGN_CASH_SELLING => array('EUR', 'AUD', 'CAD', 'HRK', 'CZK', 'DKK', 'HUF', 'JPY', 'NOK', 'RUB', 'SEK', |
44
|
|
|
'CHF', 'GBP', 'USD', 'BAM', 'PLN'), |
45
|
|
|
RateType::FOREIGN_EXCHANGE_BUYING => array('EUR', 'AUD', 'CAD', 'CNY', 'DKK', 'JPY', 'NOK', 'RUB', 'SEK', 'CHF', 'GBP', 'USD'), |
46
|
|
|
RateType::FOREIGN_EXCHANGE_SELLING => array('EUR', 'AUD', 'CAD', 'CNY', 'DKK', 'JPY', 'NOK', 'RUB', 'SEK', 'CHF', 'GBP', 'USD') |
47
|
|
|
); |
48
|
|
|
|
49
|
|
|
private function __construct() { } |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Check if Banca Intesa Serbia supports given exchange rate currency code for given rate type. |
53
|
|
|
* |
54
|
|
|
* @param string $currencyCode Currency code. |
55
|
|
|
* @param string $rateType Rate type. |
56
|
|
|
* @return bool TRUE if currency code within rate type is supported. |
57
|
|
|
*/ |
58
|
6 |
|
public static function supports($currencyCode, $rateType) |
59
|
|
|
{ |
60
|
|
|
if ( |
61
|
6 |
|
!array_key_exists($rateType, self::$supports) |
62
|
|
|
|| |
63
|
6 |
|
!in_array($currencyCode, self::$supports[$rateType], true) |
64
|
|
|
) { |
65
|
1 |
|
return false; |
66
|
|
|
} |
67
|
|
|
|
68
|
5 |
|
return true; |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|