Api   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 48
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 1 1
A supports() 0 12 3
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