@@ -61,15 +61,15 @@ discard block |
||
61 | 61 | */ |
62 | 62 | protected function boot() |
63 | 63 | { |
64 | - if(!$publicKey = $this->credential('public')) { |
|
64 | + if (!$publicKey = $this->credential('public')) { |
|
65 | 65 | throw new \InvalidArgumentException('Public key must be defined'); |
66 | 66 | } |
67 | 67 | |
68 | - if(!$secretKey = $this->credential('secret')) { |
|
68 | + if (!$secretKey = $this->credential('secret')) { |
|
69 | 69 | throw new \InvalidArgumentException('Secret key must be defined'); |
70 | 70 | } |
71 | 71 | |
72 | - if(!$this->client) { |
|
72 | + if (!$this->client) { |
|
73 | 73 | $handler = new \GuzzleHttp\HandlerStack(); |
74 | 74 | $handler->setHandler(new \GuzzleHttp\Handler\CurlHandler()); |
75 | 75 | $handler->push($this->bearerTokenHeader()); |
@@ -243,11 +243,11 @@ discard block |
||
243 | 243 | */ |
244 | 244 | public function request(string $name, array $parameters = []): array |
245 | 245 | { |
246 | - if(!$this->hasRequest($name)) { |
|
246 | + if (!$this->hasRequest($name)) { |
|
247 | 247 | throw new \InvalidArgumentException("Request `{$name}` is not supported"); |
248 | 248 | } |
249 | 249 | |
250 | - if(!method_exists($this, $name)) { |
|
250 | + if (!method_exists($this, $name)) { |
|
251 | 251 | throw new \InvalidArgumentException("Request `{$name}` listed but is not implemented"); |
252 | 252 | } |
253 | 253 | |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | */ |
278 | 278 | public function success(bool $withStatus = false): bool |
279 | 279 | { |
280 | - if(!$this->response || $this->response->getStatusCode() !== 200) { |
|
280 | + if (!$this->response || $this->response->getStatusCode() !== 200) { |
|
281 | 281 | return false; |
282 | 282 | } |
283 | 283 | |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | |
342 | 342 | $this->formatted = $decoded; |
343 | 343 | |
344 | - if($this->success()) { |
|
344 | + if ($this->success()) { |
|
345 | 345 | return $this->formatted; |
346 | 346 | } |
347 | 347 | |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | */ |
370 | 370 | private function bearerToken() |
371 | 371 | { |
372 | - if(!$token = app('auth')->token()) { |
|
372 | + if (!$token = app('auth')->token()) { |
|
373 | 373 | return null; |
374 | 374 | } |
375 | 375 | |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | public function bearerTokenHeader(): \Closure |
385 | 385 | { |
386 | 386 | return function(callable $handler) { |
387 | - return function (\Psr\Http\Message\RequestInterface $request, array $options) use ($handler) { |
|
387 | + return function(\Psr\Http\Message\RequestInterface $request, array $options) use ($handler) { |
|
388 | 388 | $request = $request->withHeader('Authorization', $this->bearerToken()); |
389 | 389 | |
390 | 390 | return $handler($request, $options); |
@@ -82,11 +82,11 @@ discard block |
||
82 | 82 | { |
83 | 83 | $this->client->request('login', compact('email', 'password', 'remember')); |
84 | 84 | |
85 | - if(!$this->client->success()) { |
|
85 | + if (!$this->client->success()) { |
|
86 | 86 | return false; |
87 | 87 | } |
88 | 88 | |
89 | - if(!$this->token = $this->client->getToken()) { |
|
89 | + if (!$this->token = $this->client->getToken()) { |
|
90 | 90 | return false; |
91 | 91 | } |
92 | 92 | |
@@ -113,11 +113,11 @@ discard block |
||
113 | 113 | { |
114 | 114 | $this->client->request('unsafeLogin', compact('email', 'remember')); |
115 | 115 | |
116 | - if(!$this->client->success()) { |
|
116 | + if (!$this->client->success()) { |
|
117 | 117 | return false; |
118 | 118 | } |
119 | 119 | |
120 | - if(!$this->token = $this->client->getToken()) { |
|
120 | + if (!$this->token = $this->client->getToken()) { |
|
121 | 121 | return false; |
122 | 122 | } |
123 | 123 | |
@@ -136,15 +136,15 @@ discard block |
||
136 | 136 | // If we've already retrieved the user for the current request we can just |
137 | 137 | // return it back immediately. We do not want to fetch the user data on |
138 | 138 | // every call to this method because that would be tremendously slow. |
139 | - if (! is_null($this->user)) { |
|
139 | + if (!is_null($this->user)) { |
|
140 | 140 | return $this->user; |
141 | 141 | } |
142 | 142 | |
143 | 143 | $user = null; |
144 | 144 | |
145 | - if($token = $this->token()) { |
|
146 | - if(!$user = $this->retrieveUserFromToken($token)) { |
|
147 | - if(!$user = $this->syncInstantly()) { |
|
145 | + if ($token = $this->token()) { |
|
146 | + if (!$user = $this->retrieveUserFromToken($token)) { |
|
147 | + if (!$user = $this->syncInstantly()) { |
|
148 | 148 | $this->logout(); |
149 | 149 | } |
150 | 150 | } |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | */ |
161 | 161 | public function token() |
162 | 162 | { |
163 | - if($this->token) { |
|
163 | + if ($this->token) { |
|
164 | 164 | return $this->token; |
165 | 165 | } |
166 | 166 | |
@@ -209,13 +209,13 @@ discard block |
||
209 | 209 | { |
210 | 210 | $data = (array) \Firebase\JWT\JWT::decode($token, env('JWT_SECRET'), ['HS256']); |
211 | 211 | } |
212 | - catch(\RuntimeException $e) { |
|
212 | + catch (\RuntimeException $e) { |
|
213 | 213 | $this->logout(); |
214 | 214 | |
215 | 215 | return null; |
216 | 216 | } |
217 | 217 | |
218 | - if(!$userId = array_get($data, 'userId')) { |
|
218 | + if (!$userId = array_get($data, 'userId')) { |
|
219 | 219 | return null; |
220 | 220 | } |
221 | 221 | |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | */ |
232 | 232 | private function syncInstantly() |
233 | 233 | { |
234 | - if($user = $this->authService->retrieveByToken()) { |
|
234 | + if ($user = $this->authService->retrieveByToken()) { |
|
235 | 235 | return $this->authService->handle('sync.create', ['remote' => $user]); |
236 | 236 | } |
237 | 237 |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | */ |
82 | 82 | public function login(string $email, string $password, bool $remember = false) |
83 | 83 | { |
84 | - if($this->disabled()) { |
|
84 | + if ($this->disabled()) { |
|
85 | 85 | return $this->handleFallback('login', compact('email', 'password', 'remember')); |
86 | 86 | } |
87 | 87 | |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | */ |
104 | 104 | public function unsafeLogin(string $email, bool $remember = false) |
105 | 105 | { |
106 | - if($this->disabled()) { |
|
106 | + if ($this->disabled()) { |
|
107 | 107 | return $this->handleFallback('unsafeLogin', compact('email', 'remember')); |
108 | 108 | } |
109 | 109 | |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | */ |
120 | 120 | public function logout() |
121 | 121 | { |
122 | - if($this->disabled()) { |
|
122 | + if ($this->disabled()) { |
|
123 | 123 | return $this->handleFallback('logout'); |
124 | 124 | } |
125 | 125 | |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | */ |
141 | 141 | public function register(int $userId, string $name, string $email, string $password) |
142 | 142 | { |
143 | - if($this->disabled()) { |
|
143 | + if ($this->disabled()) { |
|
144 | 144 | return []; |
145 | 145 | } |
146 | 146 | |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | */ |
159 | 159 | public function forgot(string $email) |
160 | 160 | { |
161 | - if($this->disabled()) { |
|
161 | + if ($this->disabled()) { |
|
162 | 162 | return $this->handleFallback('forgot', compact('email')); |
163 | 163 | } |
164 | 164 | |
@@ -179,13 +179,13 @@ discard block |
||
179 | 179 | */ |
180 | 180 | public function validatePasswordResetToken(string $token, string $email) |
181 | 181 | { |
182 | - if($this->disabled()) { |
|
182 | + if ($this->disabled()) { |
|
183 | 183 | return $this->handleFallback('validateReset', compact('token', 'email')); |
184 | 184 | } |
185 | 185 | |
186 | 186 | $response = $this->client->request('validateReset', compact('token', 'email')); |
187 | 187 | |
188 | - if(!$this->client->success(true)) { |
|
188 | + if (!$this->client->success(true)) { |
|
189 | 189 | return false; |
190 | 190 | } |
191 | 191 | |
@@ -208,13 +208,13 @@ discard block |
||
208 | 208 | { |
209 | 209 | $parameters = compact('token', 'email', 'password', 'confirmation'); |
210 | 210 | |
211 | - if($this->disabled()) { |
|
211 | + if ($this->disabled()) { |
|
212 | 212 | return $this->handleFallback('resetPassword', $parameters); |
213 | 213 | } |
214 | 214 | |
215 | 215 | $response = $this->client->request('reset', $parameters); |
216 | 216 | |
217 | - if(!$this->client->success(true)) { |
|
217 | + if (!$this->client->success(true)) { |
|
218 | 218 | return false; |
219 | 219 | } |
220 | 220 | |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | */ |
234 | 234 | public function update(int $id, ?string $name, ?string $email, ?string $password) |
235 | 235 | { |
236 | - if($this->disabled()) { |
|
236 | + if ($this->disabled()) { |
|
237 | 237 | return false; |
238 | 238 | } |
239 | 239 | |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | |
242 | 242 | $response = $this->client->request('update', compact('id', 'attributes')); |
243 | 243 | |
244 | - if(!$this->client->success(true)) { |
|
244 | + if (!$this->client->success(true)) { |
|
245 | 245 | return false; |
246 | 246 | } |
247 | 247 | |
@@ -255,13 +255,13 @@ discard block |
||
255 | 255 | */ |
256 | 256 | public function retrieveByToken() |
257 | 257 | { |
258 | - if($this->disabled()) { |
|
258 | + if ($this->disabled()) { |
|
259 | 259 | return null; |
260 | 260 | } |
261 | 261 | |
262 | 262 | $response = $this->client->request('me'); |
263 | 263 | |
264 | - if(!$this->client->success(true)) { |
|
264 | + if (!$this->client->success(true)) { |
|
265 | 265 | return null; |
266 | 266 | } |
267 | 267 | |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | { |
296 | 296 | $handler = camel_case(str_replace('.', ' ', $key)); |
297 | 297 | |
298 | - if(!method_exists($this->handlersContainer, $handler)) { |
|
298 | + if (!method_exists($this->handlersContainer, $handler)) { |
|
299 | 299 | throw new \InvalidArgumentException("Handler `{$handler}` cannot be found"); |
300 | 300 | } |
301 | 301 | |
@@ -340,10 +340,10 @@ discard block |
||
340 | 340 | try { |
341 | 341 | $output = $callback(); |
342 | 342 | } |
343 | - catch(\Exception $e) { |
|
343 | + catch (\Exception $e) { |
|
344 | 344 | DB::rollBack(); |
345 | 345 | |
346 | - if(is_null($fallback)) { |
|
346 | + if (is_null($fallback)) { |
|
347 | 347 | throw $e; |
348 | 348 | } |
349 | 349 |