1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* This file is part of the Exchange Rate package, an RunOpenCode project. |
4
|
|
|
* |
5
|
|
|
* (c) 2016 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
|
|
|
class Configuration |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* @var string |
26
|
|
|
*/ |
27
|
|
|
private $currencyCode; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var string |
31
|
|
|
*/ |
32
|
|
|
private $rateType; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @var string |
36
|
|
|
*/ |
37
|
|
|
private $sourceName; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @var array |
41
|
|
|
*/ |
42
|
|
|
private $extraConfiguration; |
43
|
|
|
|
44
|
8 |
|
public function __construct($currencyCode, $rateType, $sourceName, array $extraConfiguration = array()) |
45
|
|
|
{ |
46
|
8 |
|
$this->currencyCode = CurrencyCodeUtil::clean($currencyCode); |
47
|
8 |
|
$this->rateType = $rateType; |
48
|
8 |
|
$this->sourceName = $sourceName; |
49
|
8 |
|
$this->extraConfiguration = $extraConfiguration; |
50
|
8 |
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Get configured currency code. |
54
|
|
|
* |
55
|
|
|
* @return string |
56
|
|
|
*/ |
57
|
4 |
|
public function getCurrencyCode() |
58
|
|
|
{ |
59
|
4 |
|
return $this->currencyCode; |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* Get configured rate type. |
64
|
|
|
* |
65
|
|
|
* @return string |
66
|
|
|
*/ |
67
|
4 |
|
public function getRateType() |
68
|
|
|
{ |
69
|
4 |
|
return $this->rateType; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Get configured source. |
74
|
|
|
* |
75
|
|
|
* @return string |
76
|
|
|
*/ |
77
|
2 |
|
public function getSourceName() |
78
|
|
|
{ |
79
|
2 |
|
return $this->sourceName; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* Get additional configuration paramaters, if applicable. |
84
|
|
|
* |
85
|
|
|
* @return array |
86
|
|
|
*/ |
87
|
|
|
public function getExtraConfiguration() |
88
|
|
|
{ |
89
|
|
|
return $this->extraConfiguration; |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
|