|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* This file is part of the Exchange Rate package, an RunOpenCode project. |
|
4
|
|
|
* |
|
5
|
|
|
* (c) 2017 RunOpenCode |
|
6
|
|
|
* |
|
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
8
|
|
|
* file that was distributed with this source code. |
|
9
|
|
|
*/ |
|
10
|
|
|
namespace RunOpenCode\ExchangeRate; |
|
11
|
|
|
|
|
12
|
|
|
use RunOpenCode\ExchangeRate\Utils\CurrencyCodeUtil; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Class Configuration |
|
16
|
|
|
* |
|
17
|
|
|
* Configuration defines which rates should be acquired from which source, and holds additional custom cofiguration |
|
18
|
|
|
* parameters, if required. |
|
19
|
|
|
* |
|
20
|
|
|
* @package RunOpenCode\ExchangeRate |
|
21
|
|
|
* |
|
22
|
|
|
* @codeCoverageIgnore |
|
23
|
|
|
*/ |
|
24
|
|
|
class Configuration |
|
25
|
|
|
{ |
|
26
|
|
|
/** |
|
27
|
|
|
* @var string |
|
28
|
|
|
*/ |
|
29
|
|
|
private $currencyCode; |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* @var string |
|
33
|
|
|
*/ |
|
34
|
|
|
private $rateType; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @var string |
|
38
|
|
|
*/ |
|
39
|
|
|
private $sourceName; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @var array |
|
43
|
|
|
*/ |
|
44
|
|
|
private $extraConfiguration; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Configuration constructor. |
|
48
|
|
|
* |
|
49
|
|
|
* @param $currencyCode |
|
50
|
|
|
* @param $rateType |
|
51
|
|
|
* @param $sourceName |
|
52
|
|
|
* @param array $extraConfiguration |
|
53
|
|
|
*/ |
|
54
|
|
|
public function __construct($currencyCode, $rateType, $sourceName, array $extraConfiguration = array()) |
|
55
|
|
|
{ |
|
56
|
|
|
$this->currencyCode = CurrencyCodeUtil::clean($currencyCode); |
|
57
|
|
|
$this->rateType = $rateType; |
|
58
|
|
|
$this->sourceName = $sourceName; |
|
59
|
|
|
$this->extraConfiguration = $extraConfiguration; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* Get configured currency code. |
|
64
|
|
|
* |
|
65
|
|
|
* @return string |
|
66
|
|
|
*/ |
|
67
|
|
|
public function getCurrencyCode() |
|
68
|
|
|
{ |
|
69
|
|
|
return $this->currencyCode; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Get configured rate type. |
|
74
|
|
|
* |
|
75
|
|
|
* @return string |
|
76
|
|
|
*/ |
|
77
|
|
|
public function getRateType() |
|
78
|
|
|
{ |
|
79
|
|
|
return $this->rateType; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* Get configured source. |
|
84
|
|
|
* |
|
85
|
|
|
* @return string |
|
86
|
|
|
*/ |
|
87
|
|
|
public function getSourceName() |
|
88
|
|
|
{ |
|
89
|
|
|
return $this->sourceName; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* Get additional configuration paramaters, if applicable. |
|
94
|
|
|
* |
|
95
|
|
|
* @return array |
|
96
|
|
|
*/ |
|
97
|
|
|
public function getExtraConfiguration() |
|
98
|
|
|
{ |
|
99
|
|
|
return $this->extraConfiguration; |
|
100
|
|
|
} |
|
101
|
|
|
} |
|
102
|
|
|
|