Test Failed
Push — main ( fa2a05...1d4b01 )
by Dylan
11:10 queued 08:59
created
tests/services/ServicesTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -148,7 +148,7 @@
 block discarded – undo
148 148
         string $url,
149 149
         string $list_class = ListResource::class,
150 150
         array $params = []
151
-    ){
151
+    ) {
152 152
         $this->assertInstanceOf($list_class, $all);
153 153
         $this->assertEquals($url, $all->getURL());
154 154
         $this->assertEquals($this->getMockClient(), $all->getClient());
Please login to merge, or discard this patch.
src/App.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
     public function __construct(string $app_id, string $app_secret, $auth_domain = self::AUTH_DOMAIN)
26 26
     {
27 27
         if (!$app_id || !$app_secret) {
28
-            throw new InvalidArgumentException(static::class . "expects an app_id and app_secret");
28
+            throw new InvalidArgumentException(static::class."expects an app_id and app_secret");
29 29
         }
30 30
 
31 31
         $this->setAppID($app_id);
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 
158 158
         if (!$response->isValid() || !$json || !array_key_exists('access_token', $json)) {
159 159
             return '';
160
-        } else {
160
+        }else {
161 161
             $this->setAccessToken($json['access_token']);
162 162
             return $this->getAccessToken(false);
163 163
         }
Please login to merge, or discard this patch.
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -109,7 +109,9 @@  discard block
 block discarded – undo
109 109
      */
110 110
     public function getAPIChallenge(bool $check_session = true): string
111 111
     {
112
-        if ($this->_api_challenge) return $this->_api_challenge;
112
+        if ($this->_api_challenge) {
113
+            return $this->_api_challenge;
114
+        }
113 115
 
114 116
         if ($check_session && session_status() === PHP_SESSION_ACTIVE) {
115 117
             $this->setAPIChallenge($_SESSION[self::API_CHALLENGE_PARAM] ?? '');
@@ -169,7 +171,9 @@  discard block
 block discarded – undo
169 171
      */
170 172
     public function getAccessToken(bool $check_session = true): string
171 173
     {
172
-        if ($this->_access_token) return $this->_access_token;
174
+        if ($this->_access_token) {
175
+            return $this->_access_token;
176
+        }
173 177
 
174 178
         if ($check_session && session_status() === PHP_SESSION_ACTIVE) {
175 179
             $this->setAccessToken($_SESSION[self::ACCESS_TOKEN_PARAM] ?? '');
Please login to merge, or discard this patch.
src/utils/Curl.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
     private $_method = 'GET';
22 22
     private $_url    = '';
23 23
     private $_data    = [];
24
-    private $_isfile   = false;
24
+    private $_isfile = false;
25 25
     private $_headers = [
26 26
         'Content-Type'      => 'application/x-www-form-urlencoded',
27 27
         'X-Requested-By'    => self::USER_AGENT
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
         }
192 192
 
193 193
         if ($this->_enable_cache && $this->getMethod() === 'GET') {
194
-            $cache_key = urlencode($request_uri) . implode(',', $send_headers);
194
+            $cache_key = urlencode($request_uri).implode(',', $send_headers);
195 195
             if (array_key_exists($cache_key, self::$_cache)) {
196 196
                 return self::$_cache[$cache_key];
197 197
             }
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
         curl_setopt($ch, CURLOPT_AUTOREFERER, true);
212 212
 
213 213
         if (!empty($send_headers))  curl_setopt($ch, CURLOPT_HTTPHEADER, $send_headers);
214
-        if (!is_null($post_data))   {
214
+        if (!is_null($post_data)) {
215 215
             curl_setopt($ch, CURLOPT_POST, 1);
216 216
             curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
217 217
         }
Please login to merge, or discard this patch.
Braces   +27 added lines, -9 removed lines patch added patch discarded remove patch
@@ -39,8 +39,12 @@  discard block
 block discarded – undo
39 39
     public function __construct(string $url, array $data = [], array $headers = [])
40 40
     {
41 41
         $this->setURL($url);
42
-        foreach ($data as $name => $value)      $this->addDataParam($name, $value);
43
-        foreach ($headers as $name => $value)   $this->addHeader($name, $value);
42
+        foreach ($data as $name => $value) {
43
+            $this->addDataParam($name, $value);
44
+        }
45
+        foreach ($headers as $name => $value) {
46
+            $this->addHeader($name, $value);
47
+        }
44 48
     }
45 49
 
46 50
     /**
@@ -99,7 +103,9 @@  discard block
 block discarded – undo
99 103
 
100 104
     public function removeDataParam(string $name): Curl
101 105
     {
102
-        if (array_key_exists($name, $this->_data)) unset($this->_data[$name]);
106
+        if (array_key_exists($name, $this->_data)) {
107
+            unset($this->_data[$name]);
108
+        }
103 109
         return $this;
104 110
     }
105 111
 
@@ -128,7 +134,9 @@  discard block
 block discarded – undo
128 134
      */
129 135
     public function removeHeader(string $name): Curl
130 136
     {
131
-        if (array_key_exists($name, $this->_headers)) unset($this->_headers[$name]);
137
+        if (array_key_exists($name, $this->_headers)) {
138
+            unset($this->_headers[$name]);
139
+        }
132 140
         return $this;
133 141
     }
134 142
 
@@ -173,13 +181,17 @@  discard block
 block discarded – undo
173 181
         $request_uri    = $this->getURL();
174 182
 
175 183
         //  Headers
176
-        foreach ($this->getHeaders() as $k => $v) $send_headers[] = "{$k}: {$v}";
184
+        foreach ($this->getHeaders() as $k => $v) {
185
+            $send_headers[] = "{$k}: {$v}";
186
+        }
177 187
 
178 188
         // Request Data
179 189
         switch ($this->getMethod()) {
180 190
             case 'GET':
181 191
             case 'DELETE':
182
-                foreach ($this->getDataParams() as $name => $value) $request_uri = URL::setGetVar($name, $value, $request_uri);
192
+                foreach ($this->getDataParams() as $name => $value) {
193
+                    $request_uri = URL::setGetVar($name, $value, $request_uri);
194
+                }
183 195
                 break;
184 196
 
185 197
             case 'POST':
@@ -210,7 +222,9 @@  discard block
 block discarded – undo
210 222
         curl_setopt($ch, CURLINFO_HEADER_OUT, true);
211 223
         curl_setopt($ch, CURLOPT_AUTOREFERER, true);
212 224
 
213
-        if (!empty($send_headers))  curl_setopt($ch, CURLOPT_HTTPHEADER, $send_headers);
225
+        if (!empty($send_headers)) {
226
+            curl_setopt($ch, CURLOPT_HTTPHEADER, $send_headers);
227
+        }
214 228
         if (!is_null($post_data))   {
215 229
             curl_setopt($ch, CURLOPT_POST, 1);
216 230
             curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
@@ -219,10 +233,14 @@  discard block
 block discarded – undo
219 233
         $result     = curl_exec($ch);
220 234
         $http_code  = curl_getinfo($ch, CURLINFO_HTTP_CODE);
221 235
 
222
-        if ($http_code === 401 && $retry_on_401) return $this->curl(false);
236
+        if ($http_code === 401 && $retry_on_401) {
237
+            return $this->curl(false);
238
+        }
223 239
 
224 240
         $response = new CurlResponse((int) $http_code, (string) $result);
225
-        if ($this->_enable_cache && isset($cache_key)) self::$_cache[$cache_key] = $response;
241
+        if ($this->_enable_cache && isset($cache_key)) {
242
+            self::$_cache[$cache_key] = $response;
243
+        }
226 244
 
227 245
         return $response;
228 246
     }
Please login to merge, or discard this patch.
src/models/Order.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -93,6 +93,6 @@
 block discarded – undo
93 93
             default: return '';
94 94
         }
95 95
 
96
-        return ($value !== 0) ?  number_format($value, 2) . $this->Currency : '-';
96
+        return ($value !== 0) ?  number_format($value, 2).$this->Currency : '-';
97 97
     }
98 98
 }
Please login to merge, or discard this patch.
src/services/Orders.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
     public function fetch(int $id): ?Order
52 52
     {
53 53
         /** @var Order|null $fetch */
54
-        $fetch = $this->_get('api/orders/order/' . $id);
54
+        $fetch = $this->_get('api/orders/order/'.$id);
55 55
         return $fetch;
56 56
     }
57 57
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
     public function update(int $id, array $data): ?Order
79 79
     {
80 80
         /** @var Order|null $post */
81
-        $post = $this->_post('api/orders/order/' . $id, $data);
81
+        $post = $this->_post('api/orders/order/'.$id, $data);
82 82
         return $post;
83 83
     }
84 84
 
Please login to merge, or discard this patch.
src/models/Model.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -35,19 +35,19 @@  discard block
 block discarded – undo
35 35
                     // Model or Object
36 36
                     if (!array_key_exists('field_name', $value)) {
37 37
                         $this->$field = ObjectFactory::make($client, $value);
38
-                    } else {
38
+                    }else {
39 39
                         // Has One Relation - Deprecated
40 40
                         $name = $value['field_name'];
41 41
                         $this->$name    = $value['field_value'];
42 42
                         $this->$field   = ObjectFactory::make($client, $value['object_data']);
43 43
                     }
44
-                } else {
44
+                }else {
45 45
                     // HasMany / ManyMany Relation
46 46
                     $list = [];
47 47
                     foreach ($value as $item) {
48 48
                         if (ArrayLib::is_associative($item)) {
49 49
                             $list[] = ObjectFactory::make($client, $item);
50
-                        } else {
50
+                        }else {
51 51
                             $list[] = $item;
52 52
                         }
53 53
                     }
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
                 $data[$key] = [];
75 75
                 /** @var self $item */
76 76
                 foreach ($value as $item) $data[$key][] = $item->toArray(true);
77
-            } else $data[$key] = $value;
77
+            }else $data[$key] = $value;
78 78
         }
79 79
 
80 80
         return $data;
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
             if ($model === static::class) return new $service($this->getClient());
99 99
         }
100 100
 
101
-        throw new ErrorException("Could not determine which service to use for " . static::class);
101
+        throw new ErrorException("Could not determine which service to use for ".static::class);
102 102
     }
103 103
 
104 104
     /**
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
         if ($this->exists()) {
113 113
             if (!method_exists($service, 'update')) return $this;
114 114
             return $service->update($this->ID, $this->toArray());
115
-        } else {
115
+        }else {
116 116
             if (!method_exists($service, 'create')) return $this;
117 117
             return $service->create($this->toArray());
118 118
         }
Please login to merge, or discard this patch.
Braces   +21 added lines, -8 removed lines patch added patch discarded remove patch
@@ -64,17 +64,24 @@  discard block
 block discarded – undo
64 64
      */
65 65
     public function toArray(bool $flatten = false): array
66 66
     {
67
-        if (!$flatten) return iterator_to_array($this->getIterator());
67
+        if (!$flatten) {
68
+            return iterator_to_array($this->getIterator());
69
+        }
68 70
 
69 71
         $data = [];
70 72
 
71 73
         foreach ($this->getIterator() as $key => $value) {
72
-            if ($value instanceof self)         $data[$key] = $value->toArray(true);
73
-            else if ($value instanceof ListResource) {
74
+            if ($value instanceof self) {
75
+                $data[$key] = $value->toArray(true);
76
+            } else if ($value instanceof ListResource) {
74 77
                 $data[$key] = [];
75 78
                 /** @var self $item */
76
-                foreach ($value as $item) $data[$key][] = $item->toArray(true);
77
-            } else $data[$key] = $value;
79
+                foreach ($value as $item) {
80
+                    $data[$key][] = $item->toArray(true);
81
+                }
82
+            } else {
83
+                $data[$key] = $value;
84
+            }
78 85
         }
79 86
 
80 87
         return $data;
@@ -95,7 +102,9 @@  discard block
 block discarded – undo
95 102
     public function getService(): ApiService
96 103
     {
97 104
         foreach (ClassMap::SERVICE_MODEL as $service => $model) {
98
-            if ($model === static::class) return new $service($this->getClient());
105
+            if ($model === static::class) {
106
+                return new $service($this->getClient());
107
+            }
99 108
         }
100 109
 
101 110
         throw new ErrorException("Could not determine which service to use for " . static::class);
@@ -110,10 +119,14 @@  discard block
 block discarded – undo
110 119
         $service = $this->getService();
111 120
 
112 121
         if ($this->exists()) {
113
-            if (!method_exists($service, 'update')) return $this;
122
+            if (!method_exists($service, 'update')) {
123
+                return $this;
124
+            }
114 125
             return $service->update($this->ID, $this->toArray());
115 126
         } else {
116
-            if (!method_exists($service, 'create')) return $this;
127
+            if (!method_exists($service, 'create')) {
128
+                return $this;
129
+            }
117 130
             return $service->create($this->toArray());
118 131
         }
119 132
     }
Please login to merge, or discard this patch.