Passed
Push — master ( 6351b0...2a835b )
by Stavros
12:23
created
src/Services/CurlWrapper.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@
 block discarded – undo
68 68
     private function execute() {
69 69
       
70 70
         //For debuging 
71
-       if ($this->getCurlDebugIsEnable()){
71
+        if ($this->getCurlDebugIsEnable()){
72 72
         $parentDir = dirname(dirname(dirname(__FILE__)));
73 73
         $fp = fopen($parentDir.'/debug_viva_curl.txt', 'w');
74 74
         curl_setopt($this->ch, CURLOPT_VERBOSE, 1);
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     private function execute() {
69 69
       
70 70
         //For debuging 
71
-       if ($this->getCurlDebugIsEnable()){
71
+       if ($this->getCurlDebugIsEnable()) {
72 72
         $parentDir = dirname(dirname(dirname(__FILE__)));
73 73
         $fp = fopen($parentDir.'/debug_viva_curl.txt', 'w');
74 74
         curl_setopt($this->ch, CURLOPT_VERBOSE, 1);
@@ -80,11 +80,11 @@  discard block
 block discarded – undo
80 80
         $response = curl_exec($this->ch);
81 81
 
82 82
         //For debuging 
83
-        if ($this->getCurlDebugIsEnable()){
83
+        if ($this->getCurlDebugIsEnable()) {
84 84
             $method = __METHOD__;
85 85
             $parentDir = dirname(dirname(dirname(__FILE__)));
86
-            $fp = fopen($parentDir . '/debug_viva_curl_response.txt', 'a+');
87
-            fwrite($fp, '------- '. $method.' -------'.PHP_EOL. $response.PHP_EOL.'------------------------------'.PHP_EOL);
86
+            $fp = fopen($parentDir.'/debug_viva_curl_response.txt', 'a+');
87
+            fwrite($fp, '------- '.$method.' -------'.PHP_EOL.$response.PHP_EOL.'------------------------------'.PHP_EOL);
88 88
             fclose($fp);
89 89
         } 
90 90
 
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 
96 96
 
97 97
 
98
-            throw new \Exception('Curl error: ' . $errorMsg.' '. $errorCode);        
98
+            throw new \Exception('Curl error: '.$errorMsg.' '.$errorCode);        
99 99
         }
100 100
         
101 101
         $data = json_decode($response, true);
Please login to merge, or discard this patch.
src/Services/AccessToken.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -11,9 +11,9 @@  discard block
 block discarded – undo
11 11
     private $environment;
12 12
     private $statusCode;
13 13
 
14
-    public function __construct(string $environment = null){
14
+    public function __construct(string $environment = null) {
15 15
 
16
-        if($environment===null){
16
+        if ($environment === null) {
17 17
             $config = new Config();
18 18
             $environment = $config->getEnvConfig('defaultProvider'); 
19 19
         }
@@ -33,10 +33,10 @@  discard block
 block discarded – undo
33 33
         $curl->addHeader('Content-Type: application/x-www-form-urlencoded');
34 34
         $curl->addHeader('User-Agent: PHPGatewayRuntime/0.0.1');
35 35
         $curl->addHeader('Accept: */*');
36
-        $curl->setBasicAuth($config->getEnvConfig('VIVA_CLIENT_ID'),$config->getEnvConfig('VIVA_CLIENT_SECRET'));
36
+        $curl->setBasicAuth($config->getEnvConfig('VIVA_CLIENT_ID'), $config->getEnvConfig('VIVA_CLIENT_SECRET'));
37 37
         $response = $curl->post(array('grant_type' => 'client_credentials'));   
38 38
         $this->statusCode = $curl->getStatusCode();
39
-        $response = json_decode($response,true);
39
+        $response = json_decode($response, true);
40 40
 
41 41
         $this->accessToken = $response['access_token'];
42 42
         return $this->accessToken;
@@ -50,11 +50,11 @@  discard block
 block discarded – undo
50 50
         $curl->addHeader('Content-Type: application/x-www-form-urlencoded');
51 51
         $curl->addHeader('User-Agent: PHPGatewayRuntime/0.0.1');
52 52
         $curl->addHeader('Accept: */*');
53
-        $curl->setBasicAuth($config->getEnvConfig('VIVA_MERCHANT_ID'),$config->getEnvConfig('VIVA_API_KEY'));
53
+        $curl->setBasicAuth($config->getEnvConfig('VIVA_MERCHANT_ID'), $config->getEnvConfig('VIVA_API_KEY'));
54 54
 
55 55
         $response = $curl->get();   
56 56
 
57
-        $response = json_decode($response,true);
57
+        $response = json_decode($response, true);
58 58
         return $response;
59 59
     }
60 60
 
Please login to merge, or discard this patch.
src/Request/Customer.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
     private ?string $fullName;
20 20
     private ?string $phone;
21 21
     private ?string $countryCode;
22
-    private string|RequestLang $requestLang;
22
+    private string | RequestLang $requestLang;
23 23
 
24 24
 
25 25
     public function __construct(
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
         ?string $fullName = null,
28 28
         ?string $phone = null,
29 29
         ?string $countryCode = null,
30
-        string|RequestLang $requestLang = null,
30
+        string | RequestLang $requestLang = null,
31 31
     ) {
32 32
         $this->setEmail($email)
33 33
             ->setFullName($fullName)
Please login to merge, or discard this patch.
src/Request/CreatePaymentOrder.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
     public function getOrder()
60 60
     {
61 61
         $order = $this->order;
62
-        $order['sourceCode']  = $this->getConfigSettings()->getEnvConfig('VIVA_SOURCE_CODE');
62
+        $order['sourceCode'] = $this->getConfigSettings()->getEnvConfig('VIVA_SOURCE_CODE');
63 63
         $order['customer'] = $this->getCustomer();
64 64
         $order['paymentMethods'] = $this->paymentMethods;
65 65
         $order['paymentMethodFees'][] = $this->paymentMethodFees;
@@ -101,14 +101,14 @@  discard block
 block discarded – undo
101 101
         if ($this->getConfigSettings()->getEnvConfig('VIVA_DEBUG')) {
102 102
             $method = __METHOD__;
103 103
             $parentDir = dirname(dirname(dirname(__FILE__)));
104
-            $fp = fopen($parentDir . '/debug_viva.txt', 'a+');
105
-            fwrite($fp, '------- ' . $method . ' -------' . PHP_EOL . $this->toJson() . PHP_EOL . '------------------------------' . PHP_EOL);
104
+            $fp = fopen($parentDir.'/debug_viva.txt', 'a+');
105
+            fwrite($fp, '------- '.$method.' -------'.PHP_EOL.$this->toJson().PHP_EOL.'------------------------------'.PHP_EOL);
106 106
             fclose($fp);
107 107
         }
108 108
 
109 109
         $token = $this->accessToken->getToken();
110 110
         $url = $this->getConfigSettings()->getEnvConfig('VIVA_API_URL');
111
-        $curl = new CurlWrapper($url . '/checkout/v2/orders');
111
+        $curl = new CurlWrapper($url.'/checkout/v2/orders');
112 112
 
113 113
         $curl->addHeader('Content-Type: application/json');
114 114
         $curl->addHeader('User-Agent: PHPGatewayRuntime/0.0.1');
@@ -140,36 +140,36 @@  discard block
 block discarded – undo
140 140
 
141 141
     public function redirectUrl(
142 142
         ?string $color = null,
143
-        string|RequestLang $lang = null,
144
-        int|PaymentMethods $PaymentMethods = null
143
+        string | RequestLang $lang = null,
144
+        int | PaymentMethods $PaymentMethods = null
145 145
     ) {
146 146
         $params = '';
147 147
 
148 148
         if (!$color && $this->getConfigSettings()->getEnvConfig('VIVA_SMARTCHECKOUT_COLOR')) {
149
-            $params .= "&color=" . $this->getConfigSettings()->getEnvConfig('VIVA_SMARTCHECKOUT_COLOR');
149
+            $params .= "&color=".$this->getConfigSettings()->getEnvConfig('VIVA_SMARTCHECKOUT_COLOR');
150 150
         }
151 151
 
152
-        if ($color) $params .= "&color=" . $color;
152
+        if ($color) $params .= "&color=".$color;
153 153
 
154 154
 
155 155
         if ($lang instanceof RequestLang) {
156
-            $params .= "&lang=" . $lang->value;
156
+            $params .= "&lang=".$lang->value;
157 157
         } elseif (is_string($lang)) {
158
-            $params .= "&lang=" . $lang;
158
+            $params .= "&lang=".$lang;
159 159
         } else {
160 160
             $params .= "&lang=el-GR";
161 161
         }
162 162
 
163 163
         if ($lang instanceof PaymentMethods) {
164
-            $params .= "&paymentMethod=" . $PaymentMethods->value;
164
+            $params .= "&paymentMethod=".$PaymentMethods->value;
165 165
         } elseif (is_int($PaymentMethods)) {
166
-            $params .= "&paymentMethod=" . $PaymentMethods;
166
+            $params .= "&paymentMethod=".$PaymentMethods;
167 167
         }
168 168
 
169 169
 
170 170
 
171 171
         $orderCode = $this->vivaOrderCode;
172 172
         $url = $this->getConfigSettings()->getEnvConfig('VIVA_URL');
173
-        return $url . '/web2?ref=' . $orderCode . $params;
173
+        return $url.'/web2?ref='.$orderCode.$params;
174 174
     }
175 175
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -149,7 +149,9 @@
 block discarded – undo
149 149
             $params .= "&color=" . $this->getConfigSettings()->getEnvConfig('VIVA_SMARTCHECKOUT_COLOR');
150 150
         }
151 151
 
152
-        if ($color) $params .= "&color=" . $color;
152
+        if ($color) {
153
+            $params .= "&color=" . $color;
154
+        }
153 155
 
154 156
 
155 157
         if ($lang instanceof RequestLang) {
Please login to merge, or discard this patch.
src/Request/Transaction.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
         // https://demo.vivapayments.com/api/transactions/:transaction_id
33 33
         if (!$vivaTransaction)   throw new \Exception('Invalid transaction code');
34 34
         $url = $this->getConfigSettings()->getEnvConfig('VIVA_URL');
35
-        $curl = new CurlWrapper($url . '/api/transactions/' . $vivaTransaction);
35
+        $curl = new CurlWrapper($url.'/api/transactions/'.$vivaTransaction);
36 36
         $curl->addHeader('Content-Type: application/json');
37 37
         $curl->addHeader('User-Agent: PHPGatewayRuntime/0.0.1');
38 38
         $curl->addHeader('Accept: */*');
@@ -63,14 +63,14 @@  discard block
 block discarded – undo
63 63
         // https://demo.vivapayments.com/checkout/v2/transactions/:transaction_id
64 64
         if (!$vivaTransaction)   throw new \Exception('Invalid transaction code');
65 65
         $token = $this->accessToken->getToken();
66
-        $url = $this->getConfigSettings()->getEnvConfig('VIVA_API_URL') . '/checkout/v2/transactions/' . $vivaTransaction;
66
+        $url = $this->getConfigSettings()->getEnvConfig('VIVA_API_URL').'/checkout/v2/transactions/'.$vivaTransaction;
67 67
         $curl = new CurlWrapper($url);
68 68
         $curl->addHeader('Content-Type: application/json');
69 69
         $curl->addHeader('User-Agent: PHPGatewayRuntime/0.0.1');
70 70
         $curl->setBearer($token);
71 71
         $response = $curl->get();
72 72
         $response = json_decode($response, true);
73
-        $response['PaymentStatus'] =  Enums\TransactionStatus::fromValue($response['statusId']);
73
+        $response['PaymentStatus'] = Enums\TransactionStatus::fromValue($response['statusId']);
74 74
         $response['TransactionType'] = Enums\TransactionType::fromValue($response['transactionTypeId']);
75 75
         return $response;
76 76
     }
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
         // https://demo.vivapayments.com/api/orders/:orderCode
82 82
         if (!$orderCode)   throw new \Exception('Invalid transaction code');
83 83
         $url = $this->getConfigSettings()->getEnvConfig('VIVA_URL');
84
-        $curl = new CurlWrapper($url . '/api/orders/' . $orderCode);
84
+        $curl = new CurlWrapper($url.'/api/orders/'.$orderCode);
85 85
         $curl->addHeader('Content-Type: application/json');
86 86
         $curl->addHeader('User-Agent: PHPGatewayRuntime/0.0.1');
87 87
         $curl->addHeader('Accept: */*');
Please login to merge, or discard this patch.
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -30,7 +30,9 @@  discard block
 block discarded – undo
30 30
     public function getByTransaction($vivaTransaction)
31 31
     {
32 32
         // https://demo.vivapayments.com/api/transactions/:transaction_id
33
-        if (!$vivaTransaction)   throw new \Exception('Invalid transaction code');
33
+        if (!$vivaTransaction) {
34
+            throw new \Exception('Invalid transaction code');
35
+        }
34 36
         $url = $this->getConfigSettings()->getEnvConfig('VIVA_URL');
35 37
         $curl = new CurlWrapper($url . '/api/transactions/' . $vivaTransaction);
36 38
         $curl->addHeader('Content-Type: application/json');
@@ -61,7 +63,9 @@  discard block
 block discarded – undo
61 63
     public function getByTransactionV2($vivaTransaction)
62 64
     {
63 65
         // https://demo.vivapayments.com/checkout/v2/transactions/:transaction_id
64
-        if (!$vivaTransaction)   throw new \Exception('Invalid transaction code');
66
+        if (!$vivaTransaction) {
67
+            throw new \Exception('Invalid transaction code');
68
+        }
65 69
         $token = $this->accessToken->getToken();
66 70
         $url = $this->getConfigSettings()->getEnvConfig('VIVA_API_URL') . '/checkout/v2/transactions/' . $vivaTransaction;
67 71
         $curl = new CurlWrapper($url);
@@ -79,7 +83,9 @@  discard block
 block discarded – undo
79 83
     public function getByOrderCode($orderCode)
80 84
     {
81 85
         // https://demo.vivapayments.com/api/orders/:orderCode
82
-        if (!$orderCode)   throw new \Exception('Invalid transaction code');
86
+        if (!$orderCode) {
87
+            throw new \Exception('Invalid transaction code');
88
+        }
83 89
         $url = $this->getConfigSettings()->getEnvConfig('VIVA_URL');
84 90
         $curl = new CurlWrapper($url . '/api/orders/' . $orderCode);
85 91
         $curl->addHeader('Content-Type: application/json');
Please login to merge, or discard this patch.
src/Enums/WebhookEventType.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@
 block discarded – undo
56 56
         /**
57 57
          * Return value as string 
58 58
          * Enums\PaymentMethods::fromValue(15);
59
-        */
59
+         */
60 60
         
61 61
         public static function fromValue(int $value): string
62 62
         {
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -44,11 +44,11 @@  discard block
 block discarded – undo
44 44
     public static function fromName(string $name): int
45 45
     {
46 46
         foreach (self::cases() as $status) {
47
-            if( $name === $status->name ){
47
+            if ($name === $status->name) {
48 48
                 return $status->value;
49 49
             }
50 50
         }
51
-        throw new \ValueError("$name is not a valid backing value for enum " . self::class );
51
+        throw new \ValueError("$name is not a valid backing value for enum ".self::class);
52 52
     }
53 53
     
54 54
     
@@ -61,11 +61,11 @@  discard block
 block discarded – undo
61 61
         public static function fromValue(int $value): string
62 62
         {
63 63
             foreach (self::cases() as $status) {
64
-                if( $value === $status->value ){
64
+                if ($value === $status->value) {
65 65
                     return $status->name;
66 66
                 }
67 67
             }
68
-            throw new \ValueError("$value is not a valid backing value for enum " . self::class );
68
+            throw new \ValueError("$value is not a valid backing value for enum ".self::class);
69 69
         }
70 70
     
71 71
 
Please login to merge, or discard this patch.
src/Enums/RequestLang.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@
 block discarded – undo
40 40
     /**
41 41
      * Return value as string 
42 42
      * Enums\RequestLang::fromValue('el-GR');
43
-    */
43
+     */
44 44
     
45 45
     public static function fromValue(string $value): string
46 46
     {
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -9,8 +9,8 @@  discard block
 block discarded – undo
9 9
     case Croatian = 'hr-HR';
10 10
     case Czech = 'cs-CZ';
11 11
     case Danish = 'da-DK';
12
-    case Dutch_Netherlands  = 'nl-NL';
13
-    case Dutch_Belgium  = 'nl-BE';
12
+    case Dutch_Netherlands = 'nl-NL';
13
+    case Dutch_Belgium = 'nl-BE';
14 14
     case English_UK = 'en-GB';
15 15
     case English_US = 'en-US';
16 16
     case Finnish = 'fi-FI';
@@ -30,11 +30,11 @@  discard block
 block discarded – undo
30 30
     public static function fromName(string $name): string
31 31
     {
32 32
         foreach (self::cases() as $status) {
33
-            if( $name === $status->name ){
33
+            if ($name === $status->name) {
34 34
                 return $status->value;
35 35
             }
36 36
         }
37
-        throw new \ValueError("$name is not a valid backing value for enum " . self::class );
37
+        throw new \ValueError("$name is not a valid backing value for enum ".self::class);
38 38
     }
39 39
 
40 40
     /**
@@ -45,11 +45,11 @@  discard block
 block discarded – undo
45 45
     public static function fromValue(string $value): string
46 46
     {
47 47
         foreach (self::cases() as $status) {
48
-            if( $value === $status->value ){
48
+            if ($value === $status->value) {
49 49
                 return $status->name;
50 50
             }
51 51
         }
52
-        throw new \ValueError("$value is not a valid backing value for enum " . self::class );
52
+        throw new \ValueError("$value is not a valid backing value for enum ".self::class);
53 53
     }
54 54
 
55 55
 }
56 56
\ No newline at end of file
Please login to merge, or discard this patch.
src/Enums/TransactionStatus.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -51,22 +51,22 @@
 block discarded – undo
51 51
     public static function fromName(string $name): string
52 52
     {
53 53
         foreach (self::cases() as $status) {
54
-            if( $name === $status->name ){
54
+            if ($name === $status->name) {
55 55
                 return $status->value;
56 56
             }
57 57
         }
58
-        throw new \ValueError("$name is not a valid backing value for enum " . self::class );
58
+        throw new \ValueError("$name is not a valid backing value for enum ".self::class);
59 59
     }
60 60
 
61 61
 
62 62
     public static function fromValue(string $value): string
63 63
     {
64 64
         foreach (self::cases() as $status) {
65
-            if( $value === $status->value ){
65
+            if ($value === $status->value) {
66 66
                 return $status->name;
67 67
             }
68 68
         }
69
-        throw new \ValueError("$value is not a valid backing value for enum " . self::class );
69
+        throw new \ValueError("$value is not a valid backing value for enum ".self::class);
70 70
     }
71 71
 
72 72
 
Please login to merge, or discard this patch.
src/Enums/TransactionType.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
     /**
62 62
      * Return value as string 
63 63
      * Enums\PaymentMethods::fromName('Dias');
64
-    */
64
+     */
65 65
 
66 66
 
67 67
 public static function fromName(string $name): int
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
     /**
80 80
      * Return value as string 
81 81
      * Enums\PaymentMethods::fromValue(15);
82
-    */
82
+     */
83 83
     
84 84
     public static function fromValue(int $value): string
85 85
     {
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -67,11 +67,11 @@  discard block
 block discarded – undo
67 67
 public static function fromName(string $name): int
68 68
 {
69 69
     foreach (self::cases() as $status) {
70
-        if( $name === $status->name ){
70
+        if ($name === $status->name) {
71 71
             return $status->value;
72 72
         }
73 73
     }
74
-    throw new \ValueError("$name is not a valid backing value for enum " . self::class );
74
+    throw new \ValueError("$name is not a valid backing value for enum ".self::class);
75 75
 }
76 76
 
77 77
 
@@ -84,11 +84,11 @@  discard block
 block discarded – undo
84 84
     public static function fromValue(int $value): string
85 85
     {
86 86
         foreach (self::cases() as $status) {
87
-            if( $value === $status->value ){
87
+            if ($value === $status->value) {
88 88
                 return $status->name;
89 89
             }
90 90
         }
91
-        throw new \ValueError("$value is not a valid backing value for enum " . self::class );
91
+        throw new \ValueError("$value is not a valid backing value for enum ".self::class);
92 92
     }
93 93
 
94 94
 
Please login to merge, or discard this patch.