Passed
Push — main ( 2560cc...5cc9d7 )
by Dylan
02:43 queued 14s
created
src/Connector.php 2 patches
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.
Braces   +12 added lines, -4 removed lines patch added patch discarded remove patch
@@ -60,7 +60,9 @@  discard block
 block discarded – undo
60 60
     public function __get(string $service): ?ApiService
61 61
     {
62 62
         $obj = ServiceFactory::inst($this, $service);
63
-        if (!$obj) throw new BadMethodException("Service for `{$service}` does not exist");
63
+        if (!$obj) {
64
+            throw new BadMethodException("Service for `{$service}` does not exist");
65
+        }
64 66
 
65 67
         return $obj;
66 68
     }
@@ -118,7 +120,9 @@  discard block
 block discarded – undo
118 120
      */
119 121
     public function getHost(): ?string
120 122
     {
121
-        if (!$this->getActiveSite(true)) return null;
123
+        if (!$this->getActiveSite(true)) {
124
+            return null;
125
+        }
122 126
         return $this->_host;
123 127
     }
124 128
 
@@ -127,7 +131,9 @@  discard block
 block discarded – undo
127 131
      */
128 132
     public function getSiteKey(): ?string
129 133
     {
130
-        if (!$this->getActiveSite(true)) return null;
134
+        if (!$this->getActiveSite(true)) {
135
+            return null;
136
+        }
131 137
         return $this->_site_key;
132 138
     }
133 139
 
@@ -151,7 +157,9 @@  discard block
 block discarded – undo
151 157
         $curl->addHeader('Host', $this->getHost());
152 158
 
153 159
         foreach ($this->getAuthHeaders() as $header => $value) {
154
-            if ($value) $curl->addHeader($header, $value);
160
+            if ($value) {
161
+                $curl->addHeader($header, $value);
162
+            }
155 163
         }
156 164
 
157 165
         return $curl->curl_json();
Please login to merge, or discard this patch.
src/App.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
  */
15 15
 class App extends Connector {
16 16
 
17
-    const CODE_URL      = '/oauth/code';
17
+    const CODE_URL = '/oauth/code';
18 18
 
19 19
     const ACCESS_TOKEN_PARAM    = 'lb_app_access_token';
20 20
     const API_CHALLENGE_PARAM   = 'lb_app_api_challenge';
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
     public function __construct(string $app_id, string $app_secret, string $auth_domain = self::AUTH_DOMAIN)
32 32
     {
33 33
         if (!$app_id || !$app_secret) {
34
-            throw new InvalidArgumentException(static::class . "expects an app_id and app_secret");
34
+            throw new InvalidArgumentException(static::class."expects an app_id and app_secret");
35 35
         }
36 36
 
37 37
         $this->setAppID($app_id);
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
         if (!$response->isValid() || !$json || !array_key_exists('access_token', $json)) {
165 165
             if (array_key_exists('error', $json)) throw new OAuthException($json['error']);
166 166
             return '';
167
-        } else {
167
+        }else {
168 168
             $this->setAccessToken($json['access_token']);
169 169
 
170 170
             if (array_key_exists('store_data', $json) &&
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 
214 214
         if (!$response->isValid() || !$json || !array_key_exists('access_token', $json)) {
215 215
             throw new OAuthException($response->getError());
216
-        } else {
216
+        }else {
217 217
             $this->setAccessToken($json['access_token']);
218 218
         }
219 219
 
Please login to merge, or discard this patch.
Braces   +15 added lines, -5 removed lines patch added patch discarded remove patch
@@ -115,7 +115,9 @@  discard block
 block discarded – undo
115 115
      */
116 116
     public function getAPIChallenge(bool $check_session = true): string
117 117
     {
118
-        if ($this->_api_challenge) return $this->_api_challenge;
118
+        if ($this->_api_challenge) {
119
+            return $this->_api_challenge;
120
+        }
119 121
 
120 122
         if ($check_session && session_status() === PHP_SESSION_ACTIVE) {
121 123
             $this->setAPIChallenge($_SESSION[self::API_CHALLENGE_PARAM] ?? '');
@@ -162,7 +164,9 @@  discard block
 block discarded – undo
162 164
         $json = $response->getJSON();
163 165
         
164 166
         if (!$response->isValid() || !$json || !array_key_exists('access_token', $json)) {
165
-            if (array_key_exists('error', $json)) throw new OAuthException($json['error']);
167
+            if (array_key_exists('error', $json)) {
168
+                throw new OAuthException($json['error']);
169
+            }
166 170
             return '';
167 171
         } else {
168 172
             $this->setAccessToken($json['access_token']);
@@ -184,7 +188,9 @@  discard block
 block discarded – undo
184 188
      */
185 189
     public function getAccessToken(bool $check_session = true): string
186 190
     {
187
-        if ($this->_access_token) return $this->_access_token;
191
+        if ($this->_access_token) {
192
+            return $this->_access_token;
193
+        }
188 194
 
189 195
         if ($check_session && session_status() === PHP_SESSION_ACTIVE) {
190 196
             $this->setAccessToken($_SESSION[self::ACCESS_TOKEN_PARAM] ?? '');
@@ -252,8 +258,12 @@  discard block
 block discarded – undo
252 258
         $headers = parent::getAuthHeaders();
253 259
         $headers['app-id'] = $this->getAppID();
254 260
         
255
-        if (!$this->getAccessToken()) $this->fetchAccessToken();
256
-        if (!$this->getAccessToken()) throw new OAuthException("Access token has not been retreived");
261
+        if (!$this->getAccessToken()) {
262
+            $this->fetchAccessToken();
263
+        }
264
+        if (!$this->getAccessToken()) {
265
+            throw new OAuthException("Access token has not been retreived");
266
+        }
257 267
         
258 268
         $headers['access-token'] = $this->getAccessToken();
259 269
         
Please login to merge, or discard this patch.