@@ -5,15 +5,15 @@ |
||
5 | 5 | interface CalculateInterface |
6 | 6 | { |
7 | 7 | /** |
8 | - * currency conversion, cache check and fixer.io api connection |
|
9 | - * |
|
10 | - * @param string|array $getFrom |
|
8 | + * currency conversion, cache check and fixer.io api connection |
|
9 | + * |
|
10 | + * @param string|array $getFrom |
|
11 | 11 | * @param string|array $getTo |
12 | 12 | * @param float $amount |
13 | 13 | * @param int $short |
14 | 14 | * @param bool $isCache |
15 | 15 | * @param int $cacheTime |
16 | - * @return string|array |
|
17 | - */ |
|
16 | + * @return string|array |
|
17 | + */ |
|
18 | 18 | public function getValues($from, $to, $amount, $short, $isCache, $cacheTime); |
19 | 19 | } |
@@ -7,21 +7,21 @@ discard block |
||
7 | 7 | class Calculate implements CalculateInterface |
8 | 8 | { |
9 | 9 | /** |
10 | - * @var contains fixer.io api key string |
|
11 | - */ |
|
10 | + * @var contains fixer.io api key string |
|
11 | + */ |
|
12 | 12 | protected $api_key; |
13 | 13 | |
14 | 14 | /** |
15 | - * @const contains fixer.io API URL |
|
16 | - */ |
|
15 | + * @const contains fixer.io API URL |
|
16 | + */ |
|
17 | 17 | const API_URL = "http://data.fixer.io/api/latest"; |
18 | 18 | |
19 | 19 | /** |
20 | - * get api key |
|
21 | - * |
|
22 | - * @param string $key |
|
23 | - * @return bool |
|
24 | - */ |
|
20 | + * get api key |
|
21 | + * |
|
22 | + * @param string $key |
|
23 | + * @return bool |
|
24 | + */ |
|
25 | 25 | public function __construct($key) |
26 | 26 | { |
27 | 27 | $this->api_key = $key; |
@@ -30,12 +30,12 @@ discard block |
||
30 | 30 | } |
31 | 31 | |
32 | 32 | /** |
33 | - * change or not float decimals |
|
34 | - * |
|
35 | - * @param float $calc |
|
33 | + * change or not float decimals |
|
34 | + * |
|
35 | + * @param float $calc |
|
36 | 36 | * @param int $short |
37 | - * @return float |
|
38 | - */ |
|
37 | + * @return float |
|
38 | + */ |
|
39 | 39 | public static function roundValue($calc, $short) |
40 | 40 | { |
41 | 41 | if($short){ $number = 2; }else{ $number = 5; } |
@@ -45,16 +45,16 @@ discard block |
||
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
48 | - * currency conversion, cache check and fixer.io api connection |
|
49 | - * |
|
50 | - * @param string|array $getFrom |
|
48 | + * currency conversion, cache check and fixer.io api connection |
|
49 | + * |
|
50 | + * @param string|array $getFrom |
|
51 | 51 | * @param string|array $getTo |
52 | 52 | * @param float $amount |
53 | 53 | * @param int $short |
54 | 54 | * @param bool $isCache |
55 | 55 | * @param int $cacheTime |
56 | - * @return string|array |
|
57 | - */ |
|
56 | + * @return string|array |
|
57 | + */ |
|
58 | 58 | public function getValues($getFrom, $getTo, $amount, $short, $isCache, $cacheTime) |
59 | 59 | { |
60 | 60 | if($isCache && CacheFile::isCacheDir()){ |
@@ -118,11 +118,11 @@ discard block |
||
118 | 118 | |
119 | 119 | /** |
120 | 120 | * validate errors in conncection with fixer.io api |
121 | - * |
|
121 | + * |
|
122 | 122 | * @param string|array $data |
123 | - * @return bool |
|
123 | + * @return bool |
|
124 | 124 | * @throws Exception\InvalidArgumentException |
125 | - */ |
|
125 | + */ |
|
126 | 126 | public function validateErrors($data) |
127 | 127 | { |
128 | 128 | if(!$data->success){ |
@@ -6,10 +6,10 @@ |
||
6 | 6 | { |
7 | 7 | /** |
8 | 8 | * change cache parameter |
9 | - * |
|
10 | - * @param bool $is |
|
9 | + * |
|
10 | + * @param bool $is |
|
11 | 11 | * @param int $time |
12 | - * @return bool |
|
13 | - */ |
|
12 | + * @return bool |
|
13 | + */ |
|
14 | 14 | public static function setCache($is, $time); |
15 | 15 | } |
@@ -6,11 +6,11 @@ |
||
6 | 6 | { |
7 | 7 | /** |
8 | 8 | * change cache parameter |
9 | - * |
|
10 | - * @param bool $is |
|
9 | + * |
|
10 | + * @param bool $is |
|
11 | 11 | * @param int $time |
12 | - * @return bool |
|
13 | - */ |
|
12 | + * @return bool |
|
13 | + */ |
|
14 | 14 | public static function setCache($is, $time) |
15 | 15 | { |
16 | 16 | if($is==true && is_numeric($time) && is_int($time)){ |
@@ -6,9 +6,9 @@ discard block |
||
6 | 6 | { |
7 | 7 | /** |
8 | 8 | * check if is cache dir |
9 | - * |
|
10 | - * @return bool |
|
11 | - */ |
|
9 | + * |
|
10 | + * @return bool |
|
11 | + */ |
|
12 | 12 | public static function isCacheDir() |
13 | 13 | { |
14 | 14 | if(!is_dir(__DIR__ .'/cache/')) mkdir(__DIR__ ."/cache/", 0700); |
@@ -18,9 +18,9 @@ discard block |
||
18 | 18 | |
19 | 19 | /** |
20 | 20 | * check if cache file exists |
21 | - * |
|
22 | - * @return bool |
|
23 | - */ |
|
21 | + * |
|
22 | + * @return bool |
|
23 | + */ |
|
24 | 24 | public static function isFile() |
25 | 25 | { |
26 | 26 | $files = glob(__DIR__ .'/cache/*.txt'); |
@@ -36,9 +36,9 @@ discard block |
||
36 | 36 | |
37 | 37 | /** |
38 | 38 | * get name of cache file |
39 | - * |
|
40 | - * @return string |
|
41 | - */ |
|
39 | + * |
|
40 | + * @return string |
|
41 | + */ |
|
42 | 42 | public static function getFileName() |
43 | 43 | { |
44 | 44 | $files = glob(__DIR__ .'/cache/*.txt'); |
@@ -51,9 +51,9 @@ discard block |
||
51 | 51 | |
52 | 52 | /** |
53 | 53 | * check if cache file is needed to update |
54 | - * |
|
55 | - * @return bool |
|
56 | - */ |
|
54 | + * |
|
55 | + * @return bool |
|
56 | + */ |
|
57 | 57 | public static function isCurrent($file) |
58 | 58 | { |
59 | 59 | $getSourceName = explode(".", $file); |
@@ -71,12 +71,12 @@ discard block |
||
71 | 71 | |
72 | 72 | /** |
73 | 73 | * create new cache file |
74 | - * |
|
74 | + * |
|
75 | 75 | * @param string $file |
76 | 76 | * @param array|string $data |
77 | 77 | * @param int $time |
78 | - * @return bool |
|
79 | - */ |
|
78 | + * @return bool |
|
79 | + */ |
|
80 | 80 | public static function setNewCacheFile($file, $data, $time) |
81 | 81 | { |
82 | 82 | if($file) unlink(__DIR__ .'/cache/'.$file); |
@@ -92,9 +92,9 @@ discard block |
||
92 | 92 | |
93 | 93 | /** |
94 | 94 | * get cache data |
95 | - * |
|
96 | - * @return string |
|
97 | - */ |
|
95 | + * |
|
96 | + * @return string |
|
97 | + */ |
|
98 | 98 | public static function getCache($file) |
99 | 99 | { |
100 | 100 | $data = file_get_contents(__DIR__ .'/cache/'.$file); |
@@ -7,124 +7,124 @@ |
||
7 | 7 | |
8 | 8 | class Converter implements ConverterInterface |
9 | 9 | { |
10 | - /** |
|
11 | - * @var fixer.io api key string |
|
12 | - */ |
|
13 | - protected $api_key; |
|
14 | - |
|
15 | - /** |
|
16 | - * sortage api key lenght |
|
17 | - * |
|
18 | - * @var int |
|
19 | - */ |
|
20 | - public $api_length = 32; |
|
21 | - |
|
22 | - /** |
|
23 | - * sortage cache or not |
|
24 | - * |
|
25 | - * @var bool |
|
26 | - */ |
|
27 | - public $isCache = false; |
|
28 | - |
|
29 | - /** |
|
30 | - * contains storage cache in minutes |
|
31 | - * |
|
32 | - * @var int |
|
33 | - */ |
|
34 | - public $cacheTime = 60; |
|
35 | - |
|
36 | - /** |
|
37 | - * connect with API fixer.io |
|
38 | - * |
|
39 | - * @param string $api_key |
|
40 | - * @return bool |
|
41 | - */ |
|
42 | - public function __construct($api_key) |
|
43 | - { |
|
44 | - if(strlen($api_key)==$this->api_length){ |
|
45 | - $this->api_key = $api_key; |
|
46 | - }else{ |
|
47 | - throw new Exception\InvalidArgumentException('Invalid length of API KEY'); |
|
48 | - } |
|
49 | - |
|
50 | - return true; |
|
51 | - } |
|
52 | - |
|
53 | - /** |
|
54 | - * initial currency conversion |
|
55 | - * |
|
56 | - * @param string|array $from |
|
57 | - * @param string|array $to |
|
58 | - * @param float $amount |
|
59 | - * @param bool|int $short |
|
60 | - * @return string|array |
|
61 | - */ |
|
62 | - public function cconv($from, $to, $amount = 1, $short = false) |
|
63 | - { |
|
64 | - $getFrom = $this->checkInput($from); |
|
65 | - $getTo = $this->checkInput($to); |
|
66 | - |
|
67 | - $calculate = new Calculate($this->api_key); |
|
68 | - |
|
69 | - $output = $calculate->getValues($getFrom, $getTo, $amount, $short, $this->isCache, $this->cacheTime); |
|
70 | - |
|
71 | - return $output; |
|
72 | - } |
|
73 | - |
|
74 | - /** |
|
75 | - * validate input data |
|
76 | - * |
|
77 | - * @param string $data |
|
78 | - * @return bool |
|
79 | - */ |
|
80 | - public function validateInput($data) |
|
81 | - { |
|
82 | - if(strlen($data)==2 || strlen($data)==3){ |
|
83 | - $output = ConverterCurrency::getCurrency($data); |
|
84 | - }else{ |
|
85 | - $output = false; |
|
86 | - } |
|
87 | - return $output; |
|
88 | - } |
|
89 | - |
|
90 | - /** |
|
91 | - * initial cache or not |
|
92 | - * |
|
93 | - * @param bool $is |
|
94 | - * @param int $time |
|
95 | - * @return bool |
|
96 | - */ |
|
97 | - public function cache($is = false, $time = 60) |
|
98 | - { |
|
99 | - $parm = Cache::setCache($is, $time); |
|
100 | - $this->isCache = $parm; |
|
101 | - $this->cacheTime = $time; |
|
102 | - |
|
103 | - return true; |
|
104 | - } |
|
105 | - |
|
106 | - /** |
|
107 | - * check input data for validator |
|
108 | - * |
|
109 | - * @param string|array $data |
|
110 | - * @return string|array |
|
111 | - * @throws Exception\InvalidArgumentException |
|
112 | - */ |
|
113 | - protected function checkInput($data) |
|
114 | - { |
|
115 | - if(is_string($data)){ |
|
116 | - $value = $this->validateInput($data); |
|
117 | - if($value==false) throw new Exception\InvalidArgumentException('Invalid data. Please enter a valid country or currency name'); |
|
118 | - }else if(is_array($data)){ |
|
119 | - $value = array(); |
|
120 | - foreach($data as $single){ |
|
121 | - $opt = $this->validateInput($single); |
|
122 | - if($opt==false) throw new Exception\InvalidArgumentException('Invalid data. Please enter array with a valid country or currency names'); |
|
123 | - array_push($value, $opt); |
|
124 | - } |
|
125 | - }else{ |
|
126 | - throw new Exception\InvalidArgumentException('Invalid data. Please use string or array value'); |
|
127 | - } |
|
128 | - return $value; |
|
129 | - } |
|
10 | + /** |
|
11 | + * @var fixer.io api key string |
|
12 | + */ |
|
13 | + protected $api_key; |
|
14 | + |
|
15 | + /** |
|
16 | + * sortage api key lenght |
|
17 | + * |
|
18 | + * @var int |
|
19 | + */ |
|
20 | + public $api_length = 32; |
|
21 | + |
|
22 | + /** |
|
23 | + * sortage cache or not |
|
24 | + * |
|
25 | + * @var bool |
|
26 | + */ |
|
27 | + public $isCache = false; |
|
28 | + |
|
29 | + /** |
|
30 | + * contains storage cache in minutes |
|
31 | + * |
|
32 | + * @var int |
|
33 | + */ |
|
34 | + public $cacheTime = 60; |
|
35 | + |
|
36 | + /** |
|
37 | + * connect with API fixer.io |
|
38 | + * |
|
39 | + * @param string $api_key |
|
40 | + * @return bool |
|
41 | + */ |
|
42 | + public function __construct($api_key) |
|
43 | + { |
|
44 | + if(strlen($api_key)==$this->api_length){ |
|
45 | + $this->api_key = $api_key; |
|
46 | + }else{ |
|
47 | + throw new Exception\InvalidArgumentException('Invalid length of API KEY'); |
|
48 | + } |
|
49 | + |
|
50 | + return true; |
|
51 | + } |
|
52 | + |
|
53 | + /** |
|
54 | + * initial currency conversion |
|
55 | + * |
|
56 | + * @param string|array $from |
|
57 | + * @param string|array $to |
|
58 | + * @param float $amount |
|
59 | + * @param bool|int $short |
|
60 | + * @return string|array |
|
61 | + */ |
|
62 | + public function cconv($from, $to, $amount = 1, $short = false) |
|
63 | + { |
|
64 | + $getFrom = $this->checkInput($from); |
|
65 | + $getTo = $this->checkInput($to); |
|
66 | + |
|
67 | + $calculate = new Calculate($this->api_key); |
|
68 | + |
|
69 | + $output = $calculate->getValues($getFrom, $getTo, $amount, $short, $this->isCache, $this->cacheTime); |
|
70 | + |
|
71 | + return $output; |
|
72 | + } |
|
73 | + |
|
74 | + /** |
|
75 | + * validate input data |
|
76 | + * |
|
77 | + * @param string $data |
|
78 | + * @return bool |
|
79 | + */ |
|
80 | + public function validateInput($data) |
|
81 | + { |
|
82 | + if(strlen($data)==2 || strlen($data)==3){ |
|
83 | + $output = ConverterCurrency::getCurrency($data); |
|
84 | + }else{ |
|
85 | + $output = false; |
|
86 | + } |
|
87 | + return $output; |
|
88 | + } |
|
89 | + |
|
90 | + /** |
|
91 | + * initial cache or not |
|
92 | + * |
|
93 | + * @param bool $is |
|
94 | + * @param int $time |
|
95 | + * @return bool |
|
96 | + */ |
|
97 | + public function cache($is = false, $time = 60) |
|
98 | + { |
|
99 | + $parm = Cache::setCache($is, $time); |
|
100 | + $this->isCache = $parm; |
|
101 | + $this->cacheTime = $time; |
|
102 | + |
|
103 | + return true; |
|
104 | + } |
|
105 | + |
|
106 | + /** |
|
107 | + * check input data for validator |
|
108 | + * |
|
109 | + * @param string|array $data |
|
110 | + * @return string|array |
|
111 | + * @throws Exception\InvalidArgumentException |
|
112 | + */ |
|
113 | + protected function checkInput($data) |
|
114 | + { |
|
115 | + if(is_string($data)){ |
|
116 | + $value = $this->validateInput($data); |
|
117 | + if($value==false) throw new Exception\InvalidArgumentException('Invalid data. Please enter a valid country or currency name'); |
|
118 | + }else if(is_array($data)){ |
|
119 | + $value = array(); |
|
120 | + foreach($data as $single){ |
|
121 | + $opt = $this->validateInput($single); |
|
122 | + if($opt==false) throw new Exception\InvalidArgumentException('Invalid data. Please enter array with a valid country or currency names'); |
|
123 | + array_push($value, $opt); |
|
124 | + } |
|
125 | + }else{ |
|
126 | + throw new Exception\InvalidArgumentException('Invalid data. Please use string or array value'); |
|
127 | + } |
|
128 | + return $value; |
|
129 | + } |
|
130 | 130 | } |
@@ -4,202 +4,202 @@ |
||
4 | 4 | |
5 | 5 | class ConverterCurrency |
6 | 6 | { |
7 | - /** |
|
8 | - * country code and currency code contains gold, silver and bitcoin currency |
|
9 | - * |
|
10 | - * @var array |
|
11 | - */ |
|
12 | - protected static $countrys = array( |
|
13 | - 'AED' => 'AE', |
|
14 | - 'AFN' => 'AF', |
|
15 | - 'ALL' => 'AL', |
|
16 | - 'AMD' => 'AM', |
|
17 | - 'ANG' => 'AN', |
|
18 | - 'AOA' => 'AO', |
|
19 | - 'ARS' => 'AR', |
|
20 | - 'AUD' => 'AU', |
|
21 | - 'AWG' => 'AW', |
|
22 | - 'AZN' => 'AZ', |
|
23 | - 'BAM' => 'BA', |
|
24 | - 'BBD' => 'BB', |
|
25 | - 'BDT' => 'BD', |
|
26 | - 'BGN' => 'BG', |
|
27 | - 'BHD' => 'BH', |
|
28 | - 'BIF' => 'BI', |
|
29 | - 'BMD' => 'BM', |
|
30 | - 'BND' => 'BN', |
|
31 | - 'BOB' => 'BO', |
|
32 | - 'BRL' => 'BR', |
|
33 | - 'BSD' => 'BS', |
|
34 | - 'BTC' => 'BTC', |
|
35 | - 'BTN' => 'BT', |
|
36 | - 'BWP' => 'BW', |
|
37 | - 'BYN' => 'BY', |
|
38 | - 'BYR' => 'BY', |
|
39 | - 'BZD' => 'BZ', |
|
40 | - 'CAD' => 'CA', |
|
41 | - 'CDF' => 'CD', |
|
42 | - 'CHF' => 'LI', |
|
43 | - 'CLF' => 'CL', |
|
44 | - 'CLP' => 'CL', |
|
45 | - 'CNY' => 'CN', |
|
46 | - 'COP' => 'CO', |
|
47 | - 'CRC' => 'CR', |
|
48 | - 'CUC' => 'CU', |
|
49 | - 'CUP' => 'CU', |
|
50 | - 'CVE' => 'CV', |
|
51 | - 'CZK' => 'CZ', |
|
52 | - 'DJF' => 'DJ', |
|
53 | - 'DKK' => 'DK', |
|
54 | - 'DOP' => 'DO', |
|
55 | - 'DZD' => 'DZ', |
|
56 | - 'EGP' => 'EG', |
|
57 | - 'ERN' => 'ER', |
|
58 | - 'ETB' => 'ET', |
|
59 | - 'EUR' => 'AD', |
|
60 | - 'FJD' => 'FJ', |
|
61 | - 'FKP' => 'FK', |
|
62 | - 'GBP' => 'IO', |
|
63 | - 'GEL' => 'GE', |
|
64 | - 'GGP' => 'GG', |
|
65 | - 'GHS' => 'GH', |
|
66 | - 'GIP' => 'GI', |
|
67 | - 'GMD' => 'GM', |
|
68 | - 'GNF' => 'GN', |
|
69 | - 'GTQ' => 'GT', |
|
70 | - 'GYD' => 'GY', |
|
71 | - 'HKD' => 'HK', |
|
72 | - 'HNL' => 'HN', |
|
73 | - 'HRK' => 'HR', |
|
74 | - 'HTG' => 'HT', |
|
75 | - 'HUF' => 'HU', |
|
76 | - 'IDR' => 'ID', |
|
77 | - 'ILS' => 'IL', |
|
78 | - 'IMP' => 'IM', |
|
79 | - 'INR' => 'IN', |
|
80 | - 'IQD' => 'IQ', |
|
81 | - 'IRR' => 'IR', |
|
82 | - 'ISK' => 'IS', |
|
83 | - 'JEP' => 'JE', |
|
84 | - 'JMD' => 'JM', |
|
85 | - 'JOD' => 'JO', |
|
86 | - 'JPY' => 'JP', |
|
87 | - 'KES' => 'KE', |
|
88 | - 'KGS' => 'KG', |
|
89 | - 'KHR' => 'KH', |
|
90 | - 'KMF' => 'KM', |
|
91 | - 'KPW' => 'KP', |
|
92 | - 'KRW' => 'KR', |
|
93 | - 'KWD' => 'KW', |
|
94 | - 'KYD' => 'KY', |
|
95 | - 'KZT' => 'KZ', |
|
96 | - 'LAK' => 'LA', |
|
97 | - 'LBP' => 'LB', |
|
98 | - 'LKR' => 'LK', |
|
99 | - 'LRD' => 'LR', |
|
100 | - 'LSL' => 'LS', |
|
101 | - 'LTL' => 'LT', |
|
102 | - 'LVL' => 'LV', |
|
103 | - 'LYD' => 'LY', |
|
104 | - 'MAD' => 'MA', |
|
105 | - 'MDL' => 'MD', |
|
106 | - 'MGA' => 'MG', |
|
107 | - 'MKD' => 'MK', |
|
108 | - 'MMK' => 'MM', |
|
109 | - 'MNT' => 'MN', |
|
110 | - 'MOP' => 'MO', |
|
111 | - 'MRO' => 'MR', |
|
112 | - 'MUR' => 'MU', |
|
113 | - 'MVR' => 'MV', |
|
114 | - 'MWK' => 'MW', |
|
115 | - 'MXN' => 'MX', |
|
116 | - 'MYR' => 'MY', |
|
117 | - 'MZN' => 'MZ', |
|
118 | - 'NAD' => 'NA', |
|
119 | - 'NGN' => 'NG', |
|
120 | - 'NIO' => 'NI', |
|
121 | - 'NOK' => 'AQ', |
|
122 | - 'NPR' => 'NP', |
|
123 | - 'NZD' => 'CK', |
|
124 | - 'OMR' => 'OM', |
|
125 | - 'PAB' => 'PA', |
|
126 | - 'PEN' => 'PE', |
|
127 | - 'PGK' => 'PG', |
|
128 | - 'PHP' => 'PH', |
|
129 | - 'PKR' => 'PK', |
|
130 | - 'PLN' => 'PL', |
|
131 | - 'PYG' => 'PY', |
|
132 | - 'QAR' => 'QA', |
|
133 | - 'RON' => 'RO', |
|
134 | - 'RSD' => 'RS', |
|
135 | - 'RUB' => 'RU', |
|
136 | - 'RWF' => 'RW', |
|
137 | - 'SAR' => 'SA', |
|
138 | - 'SBD' => 'SB', |
|
139 | - 'SCR' => 'SC', |
|
140 | - 'SDG' => 'SD', |
|
141 | - 'SEK' => 'SE', |
|
142 | - 'SGD' => 'SG', |
|
143 | - 'SHP' => 'SH', |
|
144 | - 'SLL' => 'SL', |
|
145 | - 'SOS' => 'SO', |
|
146 | - 'SRD' => 'SR', |
|
147 | - 'STD' => 'ST', |
|
148 | - 'SVC' => 'SV', |
|
149 | - 'SYP' => 'SY', |
|
150 | - 'SZL' => 'SZ', |
|
151 | - 'THB' => 'TH', |
|
152 | - 'TJS' => 'TJ', |
|
153 | - 'TMT' => 'TM', |
|
154 | - 'TND' => 'TN', |
|
155 | - 'TOP' => 'TO', |
|
156 | - 'TRY' => 'TR', |
|
157 | - 'TTD' => 'TT', |
|
158 | - 'TWD' => 'TW', |
|
159 | - 'TZS' => 'TZ', |
|
160 | - 'UAH' => 'UA', |
|
161 | - 'UGX' => 'UG', |
|
162 | - 'USD' => 'AS', |
|
163 | - 'UYU' => 'UY', |
|
164 | - 'UZS' => 'UZ', |
|
165 | - 'VEF' => 'VE', |
|
166 | - 'VND' => 'VN', |
|
167 | - 'VUV' => 'VU', |
|
168 | - 'WST' => 'WS', |
|
169 | - 'XAF' => 'BJ', |
|
170 | - 'XAG' => 'XAG', |
|
171 | - 'XAU' => 'XAU', |
|
172 | - 'XCD' => 'AI', |
|
173 | - 'XDR' => 'TB', |
|
174 | - 'XOF' => 'NE', |
|
175 | - 'XPF' => 'PF', |
|
176 | - 'YER' => 'YE', |
|
177 | - 'ZAR' => 'ZA', |
|
178 | - 'ZMK' => 'ZM', |
|
179 | - 'ZMW' => 'ZM', |
|
180 | - 'ZWL' => 'ZW'); |
|
7 | + /** |
|
8 | + * country code and currency code contains gold, silver and bitcoin currency |
|
9 | + * |
|
10 | + * @var array |
|
11 | + */ |
|
12 | + protected static $countrys = array( |
|
13 | + 'AED' => 'AE', |
|
14 | + 'AFN' => 'AF', |
|
15 | + 'ALL' => 'AL', |
|
16 | + 'AMD' => 'AM', |
|
17 | + 'ANG' => 'AN', |
|
18 | + 'AOA' => 'AO', |
|
19 | + 'ARS' => 'AR', |
|
20 | + 'AUD' => 'AU', |
|
21 | + 'AWG' => 'AW', |
|
22 | + 'AZN' => 'AZ', |
|
23 | + 'BAM' => 'BA', |
|
24 | + 'BBD' => 'BB', |
|
25 | + 'BDT' => 'BD', |
|
26 | + 'BGN' => 'BG', |
|
27 | + 'BHD' => 'BH', |
|
28 | + 'BIF' => 'BI', |
|
29 | + 'BMD' => 'BM', |
|
30 | + 'BND' => 'BN', |
|
31 | + 'BOB' => 'BO', |
|
32 | + 'BRL' => 'BR', |
|
33 | + 'BSD' => 'BS', |
|
34 | + 'BTC' => 'BTC', |
|
35 | + 'BTN' => 'BT', |
|
36 | + 'BWP' => 'BW', |
|
37 | + 'BYN' => 'BY', |
|
38 | + 'BYR' => 'BY', |
|
39 | + 'BZD' => 'BZ', |
|
40 | + 'CAD' => 'CA', |
|
41 | + 'CDF' => 'CD', |
|
42 | + 'CHF' => 'LI', |
|
43 | + 'CLF' => 'CL', |
|
44 | + 'CLP' => 'CL', |
|
45 | + 'CNY' => 'CN', |
|
46 | + 'COP' => 'CO', |
|
47 | + 'CRC' => 'CR', |
|
48 | + 'CUC' => 'CU', |
|
49 | + 'CUP' => 'CU', |
|
50 | + 'CVE' => 'CV', |
|
51 | + 'CZK' => 'CZ', |
|
52 | + 'DJF' => 'DJ', |
|
53 | + 'DKK' => 'DK', |
|
54 | + 'DOP' => 'DO', |
|
55 | + 'DZD' => 'DZ', |
|
56 | + 'EGP' => 'EG', |
|
57 | + 'ERN' => 'ER', |
|
58 | + 'ETB' => 'ET', |
|
59 | + 'EUR' => 'AD', |
|
60 | + 'FJD' => 'FJ', |
|
61 | + 'FKP' => 'FK', |
|
62 | + 'GBP' => 'IO', |
|
63 | + 'GEL' => 'GE', |
|
64 | + 'GGP' => 'GG', |
|
65 | + 'GHS' => 'GH', |
|
66 | + 'GIP' => 'GI', |
|
67 | + 'GMD' => 'GM', |
|
68 | + 'GNF' => 'GN', |
|
69 | + 'GTQ' => 'GT', |
|
70 | + 'GYD' => 'GY', |
|
71 | + 'HKD' => 'HK', |
|
72 | + 'HNL' => 'HN', |
|
73 | + 'HRK' => 'HR', |
|
74 | + 'HTG' => 'HT', |
|
75 | + 'HUF' => 'HU', |
|
76 | + 'IDR' => 'ID', |
|
77 | + 'ILS' => 'IL', |
|
78 | + 'IMP' => 'IM', |
|
79 | + 'INR' => 'IN', |
|
80 | + 'IQD' => 'IQ', |
|
81 | + 'IRR' => 'IR', |
|
82 | + 'ISK' => 'IS', |
|
83 | + 'JEP' => 'JE', |
|
84 | + 'JMD' => 'JM', |
|
85 | + 'JOD' => 'JO', |
|
86 | + 'JPY' => 'JP', |
|
87 | + 'KES' => 'KE', |
|
88 | + 'KGS' => 'KG', |
|
89 | + 'KHR' => 'KH', |
|
90 | + 'KMF' => 'KM', |
|
91 | + 'KPW' => 'KP', |
|
92 | + 'KRW' => 'KR', |
|
93 | + 'KWD' => 'KW', |
|
94 | + 'KYD' => 'KY', |
|
95 | + 'KZT' => 'KZ', |
|
96 | + 'LAK' => 'LA', |
|
97 | + 'LBP' => 'LB', |
|
98 | + 'LKR' => 'LK', |
|
99 | + 'LRD' => 'LR', |
|
100 | + 'LSL' => 'LS', |
|
101 | + 'LTL' => 'LT', |
|
102 | + 'LVL' => 'LV', |
|
103 | + 'LYD' => 'LY', |
|
104 | + 'MAD' => 'MA', |
|
105 | + 'MDL' => 'MD', |
|
106 | + 'MGA' => 'MG', |
|
107 | + 'MKD' => 'MK', |
|
108 | + 'MMK' => 'MM', |
|
109 | + 'MNT' => 'MN', |
|
110 | + 'MOP' => 'MO', |
|
111 | + 'MRO' => 'MR', |
|
112 | + 'MUR' => 'MU', |
|
113 | + 'MVR' => 'MV', |
|
114 | + 'MWK' => 'MW', |
|
115 | + 'MXN' => 'MX', |
|
116 | + 'MYR' => 'MY', |
|
117 | + 'MZN' => 'MZ', |
|
118 | + 'NAD' => 'NA', |
|
119 | + 'NGN' => 'NG', |
|
120 | + 'NIO' => 'NI', |
|
121 | + 'NOK' => 'AQ', |
|
122 | + 'NPR' => 'NP', |
|
123 | + 'NZD' => 'CK', |
|
124 | + 'OMR' => 'OM', |
|
125 | + 'PAB' => 'PA', |
|
126 | + 'PEN' => 'PE', |
|
127 | + 'PGK' => 'PG', |
|
128 | + 'PHP' => 'PH', |
|
129 | + 'PKR' => 'PK', |
|
130 | + 'PLN' => 'PL', |
|
131 | + 'PYG' => 'PY', |
|
132 | + 'QAR' => 'QA', |
|
133 | + 'RON' => 'RO', |
|
134 | + 'RSD' => 'RS', |
|
135 | + 'RUB' => 'RU', |
|
136 | + 'RWF' => 'RW', |
|
137 | + 'SAR' => 'SA', |
|
138 | + 'SBD' => 'SB', |
|
139 | + 'SCR' => 'SC', |
|
140 | + 'SDG' => 'SD', |
|
141 | + 'SEK' => 'SE', |
|
142 | + 'SGD' => 'SG', |
|
143 | + 'SHP' => 'SH', |
|
144 | + 'SLL' => 'SL', |
|
145 | + 'SOS' => 'SO', |
|
146 | + 'SRD' => 'SR', |
|
147 | + 'STD' => 'ST', |
|
148 | + 'SVC' => 'SV', |
|
149 | + 'SYP' => 'SY', |
|
150 | + 'SZL' => 'SZ', |
|
151 | + 'THB' => 'TH', |
|
152 | + 'TJS' => 'TJ', |
|
153 | + 'TMT' => 'TM', |
|
154 | + 'TND' => 'TN', |
|
155 | + 'TOP' => 'TO', |
|
156 | + 'TRY' => 'TR', |
|
157 | + 'TTD' => 'TT', |
|
158 | + 'TWD' => 'TW', |
|
159 | + 'TZS' => 'TZ', |
|
160 | + 'UAH' => 'UA', |
|
161 | + 'UGX' => 'UG', |
|
162 | + 'USD' => 'AS', |
|
163 | + 'UYU' => 'UY', |
|
164 | + 'UZS' => 'UZ', |
|
165 | + 'VEF' => 'VE', |
|
166 | + 'VND' => 'VN', |
|
167 | + 'VUV' => 'VU', |
|
168 | + 'WST' => 'WS', |
|
169 | + 'XAF' => 'BJ', |
|
170 | + 'XAG' => 'XAG', |
|
171 | + 'XAU' => 'XAU', |
|
172 | + 'XCD' => 'AI', |
|
173 | + 'XDR' => 'TB', |
|
174 | + 'XOF' => 'NE', |
|
175 | + 'XPF' => 'PF', |
|
176 | + 'YER' => 'YE', |
|
177 | + 'ZAR' => 'ZA', |
|
178 | + 'ZMK' => 'ZM', |
|
179 | + 'ZMW' => 'ZM', |
|
180 | + 'ZWL' => 'ZW'); |
|
181 | 181 | |
182 | - /** |
|
183 | - * check currency code and transform country code to currency code |
|
184 | - * |
|
185 | - * @param string $data |
|
186 | - * @return string|bool |
|
187 | - */ |
|
188 | - public static function getCurrency($data) |
|
189 | - { |
|
190 | - $output = false; |
|
191 | - $base = array_flip(self::$countrys); |
|
192 | - if(strlen($data)==2){ |
|
193 | - if(array_key_exists($data, $base)) { |
|
194 | - foreach($base as $key => $value){ |
|
195 | - if($key==$data) $output = $value; |
|
196 | - } |
|
197 | - } |
|
198 | - }else{ |
|
199 | - foreach($base as $key => $value){ |
|
200 | - if($value==$data) $output = $value; |
|
201 | - } |
|
202 | - } |
|
203 | - return $output; |
|
204 | - } |
|
182 | + /** |
|
183 | + * check currency code and transform country code to currency code |
|
184 | + * |
|
185 | + * @param string $data |
|
186 | + * @return string|bool |
|
187 | + */ |
|
188 | + public static function getCurrency($data) |
|
189 | + { |
|
190 | + $output = false; |
|
191 | + $base = array_flip(self::$countrys); |
|
192 | + if(strlen($data)==2){ |
|
193 | + if(array_key_exists($data, $base)) { |
|
194 | + foreach($base as $key => $value){ |
|
195 | + if($key==$data) $output = $value; |
|
196 | + } |
|
197 | + } |
|
198 | + }else{ |
|
199 | + foreach($base as $key => $value){ |
|
200 | + if($value==$data) $output = $value; |
|
201 | + } |
|
202 | + } |
|
203 | + return $output; |
|
204 | + } |
|
205 | 205 | } |
@@ -4,14 +4,14 @@ |
||
4 | 4 | |
5 | 5 | interface ConverterInterface |
6 | 6 | { |
7 | - /** |
|
8 | - * initial currency conversion |
|
9 | - * |
|
10 | - * @param string|array $from |
|
11 | - * @param string|array $to |
|
12 | - * @param float $amount |
|
13 | - * @param bool $short |
|
14 | - * @return string|array |
|
15 | - */ |
|
16 | - public function cconv($from, $to, $amount); |
|
7 | + /** |
|
8 | + * initial currency conversion |
|
9 | + * |
|
10 | + * @param string|array $from |
|
11 | + * @param string|array $to |
|
12 | + * @param float $amount |
|
13 | + * @param bool $short |
|
14 | + * @return string|array |
|
15 | + */ |
|
16 | + public function cconv($from, $to, $amount); |
|
17 | 17 | } |