Passed
Push — main ( ffe5d2...2560cc )
by Dylan
02:31
created
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.
src/services/TaxCodes.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
     public function fetch(int $id): ?TaxCode
23 23
     {
24 24
         /** @var TaxCode|null $fetch */
25
-        $fetch = $this->_get('api/tax_code/' . $id);
25
+        $fetch = $this->_get('api/tax_code/'.$id);
26 26
         return $fetch;
27 27
     }
28 28
 
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
     public function update(int $id, array $data): ?TaxCode
50 50
     {
51 51
         /** @var TaxCode|null $post */
52
-        $post = $this->_post('api/tax_code/' . $id, $data);
52
+        $post = $this->_post('api/tax_code/'.$id, $data);
53 53
         return $post;
54 54
     }
55 55
 
Please login to merge, or discard this patch.
examples/ExampleController.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -138,7 +138,7 @@
 block discarded – undo
138 138
             // the current user has access to so that he/she can switch
139 139
             // between them
140 140
             return $this->renderWith('[[Your template]]', [
141
-               'Options' => $options
141
+                'Options' => $options
142 142
             ]);
143 143
 
144 144
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -130,7 +130,7 @@
 block discarded – undo
130 130
             foreach ($sites as $site) {
131 131
                 $options[] = [
132 132
                     'Label' => $site['domain'],
133
-                    'URL'   => $this->Link('select') . '?site_key=' . $site['site_key']
133
+                    'URL'   => $this->Link('select').'?site_key='.$site['site_key']
134 134
                 ];
135 135
             }
136 136
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -115,7 +115,9 @@
 block discarded – undo
115 115
             $sites = $this->app->getSites();
116 116
 
117 117
             // If the user doesn't have access to any Lifeboat site force a re-auth
118
-            if (count($sites) < 1) return $this->reloadAuth();
118
+            if (count($sites) < 1) {
119
+                return $this->reloadAuth();
120
+            }
119 121
 
120 122
             // If the user only has access to one Lifeboat site then automatically use that
121 123
             if (count($sites) === 1) {
Please login to merge, or discard this patch.
src/Connector.php 2 patches
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -58,7 +58,9 @@  discard block
 block discarded – undo
58 58
     public function __get(string $service): ?ApiService
59 59
     {
60 60
         $obj = ServiceFactory::inst($this, $service);
61
-        if (!$obj) throw new BadMethodException("Service for `{$service}` does not exist");
61
+        if (!$obj) {
62
+            throw new BadMethodException("Service for `{$service}` does not exist");
63
+        }
62 64
 
63 65
         return $obj;
64 66
     }
@@ -143,7 +145,9 @@  discard block
 block discarded – undo
143 145
      */
144 146
     public function getHost(): ?string
145 147
     {
146
-        if (!$this->getActiveSite(true)) return null;
148
+        if (!$this->getActiveSite(true)) {
149
+            return null;
150
+        }
147 151
         return $this->_host;
148 152
     }
149 153
 
@@ -152,7 +156,9 @@  discard block
 block discarded – undo
152 156
      */
153 157
     public function getSiteKey(): ?string
154 158
     {
155
-        if (!$this->getActiveSite(true)) return null;
159
+        if (!$this->getActiveSite(true)) {
160
+            return null;
161
+        }
156 162
         return $this->_site_key;
157 163
     }
158 164
 
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 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;
@@ -112,7 +112,7 @@  discard block
 block discarded – undo
112 112
 
113 113
         if (!$response->isValid() || !$json || !array_key_exists('access_token', $json)) {
114 114
             throw new OAuthException($response->getError());
115
-        } else {
115
+        }else {
116 116
             $this->setAccessToken($json['access_token']);
117 117
         }
118 118
 
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
     public function curl_api(string $url, string $method = 'GET', array $data = [], array $headers = []): CurlResponse
189 189
     {
190 190
         $url = URL::is_absolute_url($url) ? $url
191
-            : 'https://' . rtrim($this->getHost(), '/') . '/' . ltrim($url, '/');
191
+            : 'https://'.rtrim($this->getHost(), '/').'/'.ltrim($url, '/');
192 192
 
193 193
         $curl = new Curl($url, $data, $headers);
194 194
 
@@ -207,6 +207,6 @@  discard block
 block discarded – undo
207 207
      */
208 208
     protected function auth_url(string $path): string
209 209
     {
210
-        return rtrim($this->_auth_domain, '/') . '/' . ltrim($path, '/');
210
+        return rtrim($this->_auth_domain, '/').'/'.ltrim($path, '/');
211 211
     }
212 212
 }
Please login to merge, or discard this patch.
src/services/Locations.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
     public function fetch(int $id): ?Location
23 23
     {
24 24
         /** @var Location|null $fetch */
25
-        $fetch = $this->_get('api/locations/location/' . $id);
25
+        $fetch = $this->_get('api/locations/location/'.$id);
26 26
         return $fetch;
27 27
     }
28 28
 
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
     public function update(int $id, array $data): ?Location
50 50
     {
51 51
         /** @var Location|null $post */
52
-        $post = $this->_post('api/locations/location/' . $id, $data);
52
+        $post = $this->_post('api/locations/location/'.$id, $data);
53 53
         return $post;
54 54
     }
55 55
 
Please login to merge, or discard this patch.
src/services/DeliveryZones.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
     public function fetch(int $id): ?DeliveryZone
23 23
     {
24 24
         /** @var DeliveryZone|null $fetch */
25
-        $fetch = $this->_get('api/delivery-zones/zone/' . $id);
25
+        $fetch = $this->_get('api/delivery-zones/zone/'.$id);
26 26
         return $fetch;
27 27
     }
28 28
 
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
     public function update(int $id, array $data): ?DeliveryZone
50 50
     {
51 51
         /** @var DeliveryZone|null $post */
52
-        $post = $this->_post('api/delivery-zones/zone/' . $id, $data);
52
+        $post = $this->_post('api/delivery-zones/zone/'.$id, $data);
53 53
         return $post;
54 54
     }
55 55
 
Please login to merge, or discard this patch.