Test Failed
Push — main ( e6678b...02f88a )
by Dylan
09:26
created
src/CurlResponse.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -40,7 +40,9 @@
 block discarded – undo
40 40
     public function getJSON(): ?array
41 41
     {
42 42
         $data = json_decode($this->result, true);
43
-        if (!is_array($data)) return null;
43
+        if (!is_array($data)) {
44
+            return null;
45
+        }
44 46
         
45 47
         return $data;
46 48
     }
Please login to merge, or discard this patch.
src/utils/Utils.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
         $randomString = '';
18 18
 
19 19
         for ($i = 0; $i < $length; $i++) {
20
-            $randomString .= $characters[rand(0, $charactersLength - 1)];
20
+            $randomString .= $characters[rand(0, $charactersLength-1)];
21 21
         }
22 22
 
23 23
         return $randomString;
@@ -29,6 +29,6 @@  discard block
 block discarded – undo
29 29
      */
30 30
     public static function pack(string $str): string
31 31
     {
32
-        return rtrim(strtr(base64_encode(pack('H*',  hash('sha256', $str))), '+/', '-_'), '=');
32
+        return rtrim(strtr(base64_encode(pack('H*', hash('sha256', $str))), '+/', '-_'), '=');
33 33
     }
34 34
 }
Please login to merge, or discard this patch.
src/utils/Curl.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
         }
189 189
 
190 190
         if ($this->_enable_cache && $this->getMethod() === 'GET') {
191
-            $cache_key = urlencode($request_uri) . implode(',', $send_headers);
191
+            $cache_key = urlencode($request_uri).implode(',', $send_headers);
192 192
             if (array_key_exists($cache_key, self::$_cache)) {
193 193
                 return self::$_cache[$cache_key];
194 194
             }
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
         curl_setopt($ch, CURLOPT_AUTOREFERER, true);
209 209
 
210 210
         if (!empty($send_headers))  curl_setopt($ch, CURLOPT_HTTPHEADER, $send_headers);
211
-        if (!is_null($post_data))   {
211
+        if (!is_null($post_data)) {
212 212
             curl_setopt($ch, CURLOPT_POST, 1);
213 213
             curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
214 214
         }
Please login to merge, or discard this patch.
Braces   +24 added lines, -8 removed lines patch added patch discarded remove patch
@@ -40,8 +40,12 @@  discard block
 block discarded – undo
40 40
     public function __construct(string $url, array $data = [], array $headers = [])
41 41
     {
42 42
         $this->setURL($url);
43
-        foreach ($data as $name => $value)      $this->addDataParam($name, $value);
44
-        foreach ($headers as $name => $value)   $this->addHeader($name, $value);
43
+        foreach ($data as $name => $value) {
44
+            $this->addDataParam($name, $value);
45
+        }
46
+        foreach ($headers as $name => $value) {
47
+            $this->addHeader($name, $value);
48
+        }
45 49
     }
46 50
 
47 51
     /**
@@ -100,7 +104,9 @@  discard block
 block discarded – undo
100 104
 
101 105
     public function removeDataParam(string $name): Curl
102 106
     {
103
-        if (array_key_exists($name, $this->_data)) unset($this->_data[$name]);
107
+        if (array_key_exists($name, $this->_data)) {
108
+            unset($this->_data[$name]);
109
+        }
104 110
         return $this;
105 111
     }
106 112
 
@@ -129,7 +135,9 @@  discard block
 block discarded – undo
129 135
      */
130 136
     public function removeHeader(string $name): Curl
131 137
     {
132
-        if (array_key_exists($name, $this->_headers)) unset($this->_headers[$name]);
138
+        if (array_key_exists($name, $this->_headers)) {
139
+            unset($this->_headers[$name]);
140
+        }
133 141
         return $this;
134 142
     }
135 143
 
@@ -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);
@@ -220,7 +234,9 @@  discard block
 block discarded – undo
220 234
         $http_code  = curl_getinfo($ch, CURLINFO_HTTP_CODE);
221 235
 
222 236
         $response = new CurlResponse((int) $http_code, (string) $result);
223
-        if ($this->_enable_cache && isset($cache_key)) self::$_cache[$cache_key] = $response;
237
+        if ($this->_enable_cache && isset($cache_key)) {
238
+            self::$_cache[$cache_key] = $response;
239
+        }
224 240
 
225 241
         return $response;
226 242
     }
Please login to merge, or discard this patch.
src/Connector.php 2 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -45,7 +45,9 @@
 block discarded – undo
45 45
     public function __get(string $service): ?ApiService
46 46
     {
47 47
         $obj = ServiceFactory::inst($this, $service);
48
-        if (!$obj) throw new BadMethodException("Service for `{$service}` does not exist");
48
+        if (!$obj) {
49
+            throw new BadMethodException("Service for `{$service}` does not exist");
50
+        }
49 51
 
50 52
         return $obj;
51 53
     }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 namespace Lifeboat;
4 4
 
5
-require_once __DIR__ . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'functions.php';
5
+require_once __DIR__.DIRECTORY_SEPARATOR.'includes'.DIRECTORY_SEPARATOR.'functions.php';
6 6
 
7 7
 use Lifeboat\Exceptions\BadMethodException;
8 8
 use Lifeboat\Exceptions\OAuthException;
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
     public function curl_api(string $url, string $method = 'GET', array $data = [], array $headers = []): CurlResponse
166 166
     {
167 167
         $url = URL::is_absolute_url($url) ? $url
168
-            : 'https://' . rtrim($this->getHost(), '/') . '/' . ltrim($url, '/');
168
+            : 'https://'.rtrim($this->getHost(), '/').'/'.ltrim($url, '/');
169 169
 
170 170
         $curl = new Curl($url, $data, $headers);
171 171
 
@@ -184,6 +184,6 @@  discard block
 block discarded – undo
184 184
      */
185 185
     protected function auth_url(string $path): string
186 186
     {
187
-        return rtrim($this->_auth_domain, '/') . '/' . ltrim($path, '/');
187
+        return rtrim($this->_auth_domain, '/').'/'.ltrim($path, '/');
188 188
     }
189 189
 }
Please login to merge, or discard this patch.
src/factory/ServiceFactory.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,9 @@
 block discarded – undo
19 19
     public static function inst(Connector $connector, string $service): ?ApiService
20 20
     {
21 21
         $service = strtolower($service);
22
-        if (!array_key_exists($service, ClassMap::SERVICES)) return null;
22
+        if (!array_key_exists($service, ClassMap::SERVICES)) {
23
+            return null;
24
+        }
23 25
 
24 26
         $cls = ClassMap::SERVICES[$service];
25 27
         return new $cls($connector);
Please login to merge, or discard this patch.
src/services/ApiService.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -98,7 +98,9 @@
 block discarded – undo
98 98
     {
99 99
         $curl = $this->getClient()->curl_api($url, 'DELETE', $params);
100 100
 
101
-        if ($curl->isValid()) return true;
101
+        if ($curl->isValid()) {
102
+            return true;
103
+        }
102 104
 
103 105
         throw new ApiException($curl->getError());
104 106
     }
Please login to merge, or discard this patch.
src/services/Customers.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
     public function fetch(int $id): ?Customer
24 24
     {
25 25
         /** @var Customer|null $fetch */
26
-        $fetch = $this->_get('api/customers/customer' . $id);
26
+        $fetch = $this->_get('api/customers/customer'.$id);
27 27
         return $fetch;
28 28
     }
29 29
 
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
     public function update(int $id, array $data): ?Customer
51 51
     {
52 52
         /** @var Customer|null $post */
53
-        $post = $this->_post('api/customers/customer/' . $id, $data);
53
+        $post = $this->_post('api/customers/customer/'.$id, $data);
54 54
         return $post;
55 55
     }
56 56
 
Please login to merge, or discard this patch.
src/services/Addresses.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
     public function fetch(int $id): ?Address
24 24
     {
25 25
         /** @var Address|null $address */
26
-        $address = $this->_get('api/addresses/address' . $id);
26
+        $address = $this->_get('api/addresses/address'.$id);
27 27
         return $address;
28 28
     }
29 29
 
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
     public function update(int $id, array $data): ?Address
51 51
     {
52 52
         /** @var Address|null $address */
53
-        $address = $this->_post('api/addresses/address/' . $id, $data);
53
+        $address = $this->_post('api/addresses/address/'.$id, $data);
54 54
         return $address;
55 55
     }
56 56
 
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
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     public function fetch(int $id): ?Order
44 44
     {
45 45
         /** @var Order|null $fetch */
46
-        $fetch = $this->_get('api/orders/order' . $id);
46
+        $fetch = $this->_get('api/orders/order'.$id);
47 47
         return $fetch;
48 48
     }
49 49
 
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
     public function update(int $id, array $data): ?Order
71 71
     {
72 72
         /** @var Order|null $post */
73
-        $post = $this->_post('api/orders/order/' . $id, $data);
73
+        $post = $this->_post('api/orders/order/'.$id, $data);
74 74
         return $post;
75 75
     }
76 76
 
Please login to merge, or discard this patch.