-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCurrency.php
104 lines (95 loc) · 2.04 KB
/
Currency.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?php
/**
* KlarnaCurrency
*
* PHP Version 5.3
*
* @category Payment
* @package KlarnaAPI
* @author MS Dev <ms.modules@klarna.com>
* @copyright 2012 Klarna AB (http://klarna.com)
* @license http://opensource.org/licenses/BSD-2-Clause BSD-2
* @link https://developers.klarna.com/
*/
/**
* Currency Constants class
*
* @category Payment
* @package KlarnaAPI
* @author MS Dev <ms.modules@klarna.com>
* @copyright 2012 Klarna AB (http://klarna.com)
* @license http://opensource.org/licenses/BSD-2-Clause BSD-2
* @link https://developers.klarna.com/
*/
class KlarnaCurrency
{
/**
* Currency constant for Swedish Crowns (SEK).
*
* @var int
*/
const SEK = 0;
/**
* Currency constant for Norwegian Crowns (NOK).
*
* @var int
*/
const NOK = 1;
/**
* Currency constant for Euro.
*
* @var int
*/
const EUR = 2;
/**
* Currency constant for Danish Crowns (DKK).
*
* @var int
*/
const DKK = 3;
/**
* Converts a currency code, e.g. 'eur' to the KlarnaCurrency constant.
*
* @param string $val currency code
*
* @return int|null
*/
public static function fromCode($val)
{
switch(strtolower($val)) {
case 'dkk':
return self::DKK;
case 'eur':
case 'euro':
return self::EUR;
case 'nok':
return self::NOK;
case 'sek':
return self::SEK;
default:
return null;
}
}
/**
* Converts a KlarnaCurrency constant to the respective language code.
*
* @param int $val KlarnaCurrency constant
*
* @return string|null
*/
public static function getCode($val)
{
switch($val) {
case self::DKK:
return 'dkk';
case self::EUR:
return 'eur';
case self::NOK:
return 'nok';
case self::SEK:
return 'sek';
default:
return null;
}
}
}