Passed
Push — master ( 3fd782...62ead3 )
by Patryk
05:45 queued 04:28
created
index.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 	
3
-	require __DIR__ .'/vendor/autoload.php';
3
+	require __DIR__.'/vendor/autoload.php';
4 4
 	
5 5
 	$value = new CConverter\Converter('YOUR_API_KEY');
6 6
 	echo $value->cconv('EUR', 'USD');
Please login to merge, or discard this patch.
src/Converter.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -41,9 +41,9 @@  discard block
 block discarded – undo
41 41
      */
42 42
     public function __construct($api_key)
43 43
     {
44
-        if(strlen($api_key)==$this->api_length){
44
+        if (strlen($api_key)==$this->api_length) {
45 45
             $this->api_key = $api_key;
46
-        }else{
46
+        }else {
47 47
             throw new Exception\InvalidArgumentException('Invalid length of API KEY');
48 48
         }
49 49
 
@@ -79,9 +79,9 @@  discard block
 block discarded – undo
79 79
      */
80 80
     public function validateInput($data)
81 81
     {
82
-        if(strlen($data)==2 || strlen($data)==3){
82
+        if (strlen($data)==2 || strlen($data)==3) {
83 83
             $output = ConverterCurrency::getCurrency($data);
84
-        }else{
84
+        }else {
85 85
             $output = false;
86 86
         }
87 87
         return $output;
@@ -112,17 +112,17 @@  discard block
 block discarded – undo
112 112
      */
113 113
     protected function checkInput($data)
114 114
     {
115
-        if(is_string($data)){
115
+        if (is_string($data)) {
116 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)){
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 119
             $value = array();
120
-            foreach($data as $single){
120
+            foreach ($data as $single) {
121 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');
122
+                if ($opt==false) throw new Exception\InvalidArgumentException('Invalid data. Please enter array with a valid country or currency names');
123 123
                 array_push($value, $opt);
124 124
             }
125
-        }else{
125
+        }else {
126 126
             throw new Exception\InvalidArgumentException('Invalid data. Please use string or array value');
127 127
         }
128 128
         return $value;
Please login to merge, or discard this patch.
src/ConverterCurrency.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -189,15 +189,15 @@
 block discarded – undo
189 189
     {
190 190
         $output = false;
191 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;
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 196
                 }
197 197
             }
198
-        }else{
199
-            foreach($base as $key => $value){
200
-                if($value==$data) $output = $value;
198
+        }else {
199
+            foreach ($base as $key => $value) {
200
+                if ($value==$data) $output = $value;
201 201
             }
202 202
         }
203 203
         return $output;
Please login to merge, or discard this patch.
src/Cache/CacheFile.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
      */
12 12
     public static function isCacheDir()
13 13
     {
14
-        if(!is_dir(__DIR__ .'/cache/')) mkdir(__DIR__ ."/cache/", 0700);
14
+        if (!is_dir(__DIR__.'/cache/')) mkdir(__DIR__."/cache/", 0700);
15 15
 
16 16
         return true;
17 17
     }
@@ -23,11 +23,11 @@  discard block
 block discarded – undo
23 23
      */
24 24
     public static function isFile()
25 25
     {
26
-        $files = glob(__DIR__ .'/cache/*.txt');
26
+        $files = glob(__DIR__.'/cache/*.txt');
27 27
         $count = count($files);
28
-        if($count>0){
28
+        if ($count>0) {
29 29
             $output = true;
30
-        }else{
30
+        }else {
31 31
             $output = false;
32 32
         }
33 33
 
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
      */
42 42
     public static function getFileName()
43 43
     {
44
-        $files = glob(__DIR__ .'/cache/*.txt');
44
+        $files = glob(__DIR__.'/cache/*.txt');
45 45
         $file = $files[0];
46 46
         $fileName = explode("/cache/", $file);
47 47
         $fileName = $fileName[1];
@@ -60,9 +60,9 @@  discard block
 block discarded – undo
60 60
         $getSourceName = $getSourceName[0];
61 61
 
62 62
         $current_time = time();
63
-        if($current_time>$getSourceName){
63
+        if ($current_time>$getSourceName) {
64 64
                 $output = false;
65
-        }else{
65
+        }else {
66 66
                 $output = true;
67 67
         }
68 68
 
@@ -79,13 +79,13 @@  discard block
 block discarded – undo
79 79
      */
80 80
     public static function setNewCacheFile($file, $data, $time)
81 81
     {
82
-        if($file) unlink(__DIR__ .'/cache/'.$file);
82
+        if ($file) unlink(__DIR__.'/cache/'.$file);
83 83
 
84 84
         $current_time = time();
85 85
         $new_time = $current_time + $time*60;
86 86
 
87 87
         $file_name = $new_time.".txt";
88
-        file_put_contents(__DIR__ .'/cache/'.$file_name, $data);
88
+        file_put_contents(__DIR__.'/cache/'.$file_name, $data);
89 89
 
90 90
         return true;
91 91
     }
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
      */
98 98
     public static function getCache($file)
99 99
     {
100
-        $data = file_get_contents(__DIR__ .'/cache/'.$file);
100
+        $data = file_get_contents(__DIR__.'/cache/'.$file);
101 101
 
102 102
         return $data;
103 103
     }
Please login to merge, or discard this patch.
src/Cache/Cache.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,9 +13,9 @@
 block discarded – undo
13 13
      */
14 14
     public static function setCache($is, $time)
15 15
     {
16
-        if($is==true && is_numeric($time) && is_int($time)){
16
+        if ($is==true && is_numeric($time) && is_int($time)) {
17 17
             $output = true;
18
-        }else{
18
+        }else {
19 19
             $output = false;
20 20
         }
21 21
         return $output;
Please login to merge, or discard this patch.
src/Calculate/Calculate.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
      */
39 39
     public static function roundValue($calc, $short)
40 40
     {
41
-            if($short){ $number = 2; }else{ $number = 5; }
41
+            if ($short) { $number = 2; }else { $number = 5; }
42 42
             $output = round($calc, $number);
43 43
 
44 44
             return $output;
@@ -57,62 +57,62 @@  discard block
 block discarded – undo
57 57
      */
58 58
     public function getValues($getFrom, $getTo, $amount, $short, $isCache, $cacheTime)
59 59
     {
60
-        if($isCache && CacheFile::isCacheDir()){
61
-            if(CacheFile::isFile()){
60
+        if ($isCache && CacheFile::isCacheDir()) {
61
+            if (CacheFile::isFile()) {
62 62
                 $file = CacheFile::getFileName();
63
-                if(CacheFile::isCurrent($file)){
63
+                if (CacheFile::isCurrent($file)) {
64 64
                     $data = CacheFile::getCache($file);
65
-                }else{
65
+                }else {
66 66
                     $data = file_get_contents(self::API_URL."?access_key=".$this->api_key);
67 67
                     CacheFile::setNewCacheFile($file, $data, $cacheTime);
68 68
                 }
69
-            }else{
69
+            }else {
70 70
                 $data = file_get_contents(self::API_URL."?access_key=".$this->api_key);
71 71
                 CacheFile::setNewCacheFile(false, $data, $cacheTime);
72 72
             }
73
-        }else{
73
+        }else {
74 74
             $data = file_get_contents(self::API_URL."?access_key=".$this->api_key);
75 75
         }
76 76
         $data = json_decode($data);
77 77
 
78
-        if($this->validateErrors($data)){
79
-            if(is_array($getFrom) || is_array($getTo)){
78
+        if ($this->validateErrors($data)) {
79
+            if (is_array($getFrom) || is_array($getTo)) {
80 80
                 $newArray = array();
81 81
 
82
-                if(is_array($getFrom)){
83
-                    if(is_array($getTo)){
84
-                        foreach($getFrom as $currency){
82
+                if (is_array($getFrom)) {
83
+                    if (is_array($getTo)) {
84
+                        foreach ($getFrom as $currency) {
85 85
                             $getA = $data->rates->$currency;
86
-                            foreach($getTo as $currency2){
86
+                            foreach ($getTo as $currency2) {
87 87
                                 $getB = $data->rates->$currency2;
88
-                                $calc = Calculate::roundValue(($amount * $getB)/$getA, $short);
88
+                                $calc = Calculate::roundValue(($amount*$getB)/$getA, $short);
89 89
                                 array_push($newArray, array($currency, array($currency2 => $calc)));
90 90
                             }
91 91
                         }
92
-                    }else{
93
-                        foreach($getFrom as $currency){
92
+                    }else {
93
+                        foreach ($getFrom as $currency) {
94 94
                             $getA = $data->rates->$currency;
95 95
                             $getB = $data->rates->$getTo;
96
-                            $calc = Calculate::roundValue(($amount * $getB)/$getA, $short);
96
+                            $calc = Calculate::roundValue(($amount*$getB)/$getA, $short);
97 97
                             array_push($newArray, array($currency, array($getTo => $calc)));
98 98
                         }
99 99
                     }
100
-                }else{
101
-                    foreach($getTo as $currency){
100
+                }else {
101
+                    foreach ($getTo as $currency) {
102 102
                         $getA = $data->rates->$getFrom;
103 103
                         $getB = $data->rates->$currency;
104
-                        $calc = Calculate::roundValue(($amount * $getB)/$getA, $short);
104
+                        $calc = Calculate::roundValue(($amount*$getB)/$getA, $short);
105 105
                         array_push($newArray, array($getFrom, array($currency => $calc)));
106 106
                     }
107 107
                 }
108 108
                 $output = $newArray;
109
-            }else{
109
+            }else {
110 110
                 $getA = $data->rates->$getFrom;
111 111
                 $getB = $data->rates->$getTo;
112 112
 
113
-                $output = Calculate::roundValue(($amount * $getB)/$getA, $short);
113
+                $output = Calculate::roundValue(($amount*$getB)/$getA, $short);
114 114
             }
115
-        }else{
115
+        }else {
116 116
             $output = false;
117 117
         }
118 118
         
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
      */
129 129
     public function validateErrors($data)
130 130
     {
131
-        if(!$data->success){
131
+        if (!$data->success) {
132 132
             $getErrorCode = $data->error->code;
133 133
             $getErrorInfo = $data->error->info;
134 134
             throw new \InvalidArgumentException("[$getErrorCode] $getErrorInfo");
Please login to merge, or discard this patch.