@@ -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){ |
@@ -7,10 +7,10 @@ discard block |
||
| 7 | 7 | /** |
| 8 | 8 | * country code and currency code contains gold, silver and bitcoin currency |
| 9 | 9 | * |
| 10 | - * @var array |
|
| 11 | - */ |
|
| 10 | + * @var array |
|
| 11 | + */ |
|
| 12 | 12 | protected static $countrys = array( |
| 13 | - 'AED' => 'AE', |
|
| 13 | + 'AED' => 'AE', |
|
| 14 | 14 | 'AFN' => 'AF', |
| 15 | 15 | 'ALL' => 'AL', |
| 16 | 16 | 'AMD' => 'AM', |
@@ -178,14 +178,14 @@ discard block |
||
| 178 | 178 | 'ZMK' => 'ZM', |
| 179 | 179 | 'ZMW' => 'ZM', |
| 180 | 180 | 'ZWL' => 'ZW' |
| 181 | - ); |
|
| 181 | + ); |
|
| 182 | 182 | |
| 183 | 183 | /** |
| 184 | 184 | * check currency code and transform country code to currency code |
| 185 | - * |
|
| 185 | + * |
|
| 186 | 186 | * @param string|array $data |
| 187 | - * @return string|array|bool |
|
| 188 | - */ |
|
| 187 | + * @return string|array|bool |
|
| 188 | + */ |
|
| 189 | 189 | public static function getCurrency($data) |
| 190 | 190 | { |
| 191 | 191 | $base = array_flip(self::$countrys); |
@@ -8,37 +8,37 @@ discard block |
||
| 8 | 8 | class Converter implements ConverterInterface |
| 9 | 9 | { |
| 10 | 10 | /** |
| 11 | - * @var contains fixer.io api key string |
|
| 12 | - */ |
|
| 11 | + * @var contains fixer.io api key string |
|
| 12 | + */ |
|
| 13 | 13 | protected $api_key; |
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | 16 | * sortage api key lenght |
| 17 | 17 | * |
| 18 | - * @var int |
|
| 19 | - */ |
|
| 18 | + * @var int |
|
| 19 | + */ |
|
| 20 | 20 | public $api_length = 32; |
| 21 | 21 | |
| 22 | 22 | /** |
| 23 | 23 | * sortage cache or not |
| 24 | - * |
|
| 25 | - * @var bool |
|
| 26 | - */ |
|
| 24 | + * |
|
| 25 | + * @var bool |
|
| 26 | + */ |
|
| 27 | 27 | public $isCache = false; |
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * contains storage cache in minutes |
| 31 | 31 | * |
| 32 | - * @var int |
|
| 33 | - */ |
|
| 32 | + * @var int |
|
| 33 | + */ |
|
| 34 | 34 | public $cacheTime = 60; |
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | - * connect with API fixer.io |
|
| 38 | - * |
|
| 39 | - * @param string $api_key |
|
| 40 | - * @return bool |
|
| 41 | - */ |
|
| 37 | + * connect with API fixer.io |
|
| 38 | + * |
|
| 39 | + * @param string $api_key |
|
| 40 | + * @return bool |
|
| 41 | + */ |
|
| 42 | 42 | public function __construct($api_key) |
| 43 | 43 | { |
| 44 | 44 | if(strlen($api_key)==$this->api_length){ |
@@ -52,13 +52,13 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | /** |
| 54 | 54 | * initial currency conversion |
| 55 | - * |
|
| 56 | - * @param string|array $from |
|
| 55 | + * |
|
| 56 | + * @param string|array $from |
|
| 57 | 57 | * @param string|array $to |
| 58 | 58 | * @param float $amount |
| 59 | 59 | * @param bool $short |
| 60 | - * @return string|array |
|
| 61 | - */ |
|
| 60 | + * @return string|array |
|
| 61 | + */ |
|
| 62 | 62 | public function cconv($from, $to, $amount = 1, $short = false) |
| 63 | 63 | { |
| 64 | 64 | $getFrom = $this->checkInput($from); |
@@ -73,10 +73,10 @@ discard block |
||
| 73 | 73 | |
| 74 | 74 | /** |
| 75 | 75 | * validate input data |
| 76 | - * |
|
| 76 | + * |
|
| 77 | 77 | * @param string $data |
| 78 | - * @return bool |
|
| 79 | - */ |
|
| 78 | + * @return bool |
|
| 79 | + */ |
|
| 80 | 80 | public function validateInput($data) |
| 81 | 81 | { |
| 82 | 82 | if(strlen($data)==2 || strlen($data)==3){ |
@@ -89,11 +89,11 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | /** |
| 91 | 91 | * initial cache or not |
| 92 | - * |
|
| 92 | + * |
|
| 93 | 93 | * @param bool $is |
| 94 | 94 | * @param int $time |
| 95 | - * @return bool |
|
| 96 | - */ |
|
| 95 | + * @return bool |
|
| 96 | + */ |
|
| 97 | 97 | public function cache($is = false, $time = 60) |
| 98 | 98 | { |
| 99 | 99 | $parm = Cache::setCache($is, $time); |
@@ -105,11 +105,11 @@ discard block |
||
| 105 | 105 | |
| 106 | 106 | /** |
| 107 | 107 | * check input data for validator |
| 108 | - * |
|
| 108 | + * |
|
| 109 | 109 | * @param string|array $data |
| 110 | - * @return string|array |
|
| 110 | + * @return string|array |
|
| 111 | 111 | * @throws Exception\InvalidArgumentException |
| 112 | - */ |
|
| 112 | + */ |
|
| 113 | 113 | protected function checkInput($data) |
| 114 | 114 | { |
| 115 | 115 | if(is_string($data)){ |
@@ -6,12 +6,12 @@ |
||
| 6 | 6 | { |
| 7 | 7 | /** |
| 8 | 8 | * initial currency conversion |
| 9 | - * |
|
| 10 | - * @param string|array $from |
|
| 9 | + * |
|
| 10 | + * @param string|array $from |
|
| 11 | 11 | * @param string|array $to |
| 12 | 12 | * @param float $amount |
| 13 | 13 | * @param bool $short |
| 14 | - * @return string|array |
|
| 15 | - */ |
|
| 14 | + * @return string|array |
|
| 15 | + */ |
|
| 16 | 16 | public function cconv($from, $to, $amount); |
| 17 | 17 | } |
@@ -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 $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 array |
|
| 97 | - */ |
|
| 95 | + * |
|
| 96 | + * @return array |
|
| 97 | + */ |
|
| 98 | 98 | public static function getCache($file) |
| 99 | 99 | { |
| 100 | 100 | $data = file_get_contents(__DIR__ .'/cache/'.$file); |
@@ -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)){ |