@@ -383,7 +383,7 @@ |
||
383 | 383 | $this->log(null, $decoded ?? []); |
384 | 384 | |
385 | 385 | if($this->success()) { |
386 | - return $this->formatted; |
|
386 | + return $this->formatted; |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | $message = Arr::get($this->formatted, 'message'); |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | */ |
84 | 84 | public function login(string $email, string $password, bool $remember = false) |
85 | 85 | { |
86 | - if($this->disabled()) { |
|
86 | + if ($this->disabled()) { |
|
87 | 87 | return $this->handleFallback('login', compact('email', 'password', 'remember')); |
88 | 88 | } |
89 | 89 | |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | */ |
106 | 106 | public function unsafeLogin(string $email, bool $remember = false) |
107 | 107 | { |
108 | - if($this->disabled()) { |
|
108 | + if ($this->disabled()) { |
|
109 | 109 | return $this->handleFallback('unsafeLogin', compact('email', 'remember')); |
110 | 110 | } |
111 | 111 | |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | */ |
122 | 122 | public function logout() |
123 | 123 | { |
124 | - if($this->disabled()) { |
|
124 | + if ($this->disabled()) { |
|
125 | 125 | return $this->handleFallback('logout'); |
126 | 126 | } |
127 | 127 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | */ |
144 | 144 | public function register(int $userId, string $name, string $email, string $password, string $country) |
145 | 145 | { |
146 | - if($this->disabled()) { |
|
146 | + if ($this->disabled()) { |
|
147 | 147 | return []; |
148 | 148 | } |
149 | 149 | |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | */ |
162 | 162 | public function forgot(string $email) |
163 | 163 | { |
164 | - if($this->disabled()) { |
|
164 | + if ($this->disabled()) { |
|
165 | 165 | return $this->handleFallback('forgot', compact('email')); |
166 | 166 | } |
167 | 167 | |
@@ -182,13 +182,13 @@ discard block |
||
182 | 182 | */ |
183 | 183 | public function validatePasswordResetToken(string $token, string $email) |
184 | 184 | { |
185 | - if($this->disabled()) { |
|
185 | + if ($this->disabled()) { |
|
186 | 186 | return $this->handleFallback('validateReset', compact('token', 'email')); |
187 | 187 | } |
188 | 188 | |
189 | 189 | $response = $this->client->request('validateReset', compact('token', 'email')); |
190 | 190 | |
191 | - if(!$this->client->success(true)) { |
|
191 | + if (!$this->client->success(true)) { |
|
192 | 192 | return false; |
193 | 193 | } |
194 | 194 | |
@@ -211,13 +211,13 @@ discard block |
||
211 | 211 | { |
212 | 212 | $parameters = compact('token', 'email', 'password', 'confirmation'); |
213 | 213 | |
214 | - if($this->disabled()) { |
|
214 | + if ($this->disabled()) { |
|
215 | 215 | return $this->handleFallback('resetPassword', $parameters); |
216 | 216 | } |
217 | 217 | |
218 | 218 | $response = $this->client->request('reset', $parameters); |
219 | 219 | |
220 | - if(!$this->client->success(true)) { |
|
220 | + if (!$this->client->success(true)) { |
|
221 | 221 | return false; |
222 | 222 | } |
223 | 223 | |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | */ |
238 | 238 | public function update(int $id, ?string $name, ?string $email, ?string $password, ?string $country) |
239 | 239 | { |
240 | - if($this->disabled()) { |
|
240 | + if ($this->disabled()) { |
|
241 | 241 | return false; |
242 | 242 | } |
243 | 243 | |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | |
246 | 246 | $response = $this->client->request('update', compact('id', 'attributes')); |
247 | 247 | |
248 | - if(!$this->client->success(true)) { |
|
248 | + if (!$this->client->success(true)) { |
|
249 | 249 | return false; |
250 | 250 | } |
251 | 251 | |
@@ -261,13 +261,13 @@ discard block |
||
261 | 261 | */ |
262 | 262 | public function delete(int $id) |
263 | 263 | { |
264 | - if($this->disabled()) { |
|
264 | + if ($this->disabled()) { |
|
265 | 265 | return false; |
266 | 266 | } |
267 | 267 | |
268 | 268 | $response = $this->client->request('delete', compact('id')); |
269 | 269 | |
270 | - if(!$this->client->success(true)) { |
|
270 | + if (!$this->client->success(true)) { |
|
271 | 271 | return false; |
272 | 272 | } |
273 | 273 | |
@@ -283,13 +283,13 @@ discard block |
||
283 | 283 | */ |
284 | 284 | public function restore(int $id) |
285 | 285 | { |
286 | - if($this->disabled()) { |
|
286 | + if ($this->disabled()) { |
|
287 | 287 | return false; |
288 | 288 | } |
289 | 289 | |
290 | 290 | $response = $this->client->request('restore', compact('id')); |
291 | 291 | |
292 | - if(!$this->client->success(true)) { |
|
292 | + if (!$this->client->success(true)) { |
|
293 | 293 | return false; |
294 | 294 | } |
295 | 295 | |
@@ -303,18 +303,18 @@ discard block |
||
303 | 303 | */ |
304 | 304 | public function retrieveByToken() |
305 | 305 | { |
306 | - if($this->disabled()) { |
|
306 | + if ($this->disabled()) { |
|
307 | 307 | return null; |
308 | 308 | } |
309 | 309 | |
310 | 310 | try { |
311 | 311 | $response = $this->client->request('me'); |
312 | 312 | } |
313 | - catch(\Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException $e) { |
|
313 | + catch (\Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException $e) { |
|
314 | 314 | return null; |
315 | 315 | } |
316 | 316 | |
317 | - if(!$this->client->success(true)) { |
|
317 | + if (!$this->client->success(true)) { |
|
318 | 318 | return null; |
319 | 319 | } |
320 | 320 | |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | { |
349 | 349 | $handler = Str::camel(str_replace('.', ' ', $key)); |
350 | 350 | |
351 | - if(!method_exists($this->handlersContainer, $handler)) { |
|
351 | + if (!method_exists($this->handlersContainer, $handler)) { |
|
352 | 352 | throw new \InvalidArgumentException("Handler `{$handler}` cannot be found"); |
353 | 353 | } |
354 | 354 | |
@@ -388,11 +388,11 @@ discard block |
||
388 | 388 | { |
389 | 389 | $cache = new Cache(); |
390 | 390 | |
391 | - if(!func_num_args()) { |
|
391 | + if (!func_num_args()) { |
|
392 | 392 | return $cache; |
393 | 393 | } |
394 | 394 | |
395 | - if(func_num_args() === 1) { |
|
395 | + if (func_num_args() === 1) { |
|
396 | 396 | return $cache->get($key); |
397 | 397 | } |
398 | 398 | |
@@ -412,11 +412,11 @@ discard block |
||
412 | 412 | { |
413 | 413 | $cache = new Cache(); |
414 | 414 | |
415 | - if(func_num_args() === 1) { |
|
415 | + if (func_num_args() === 1) { |
|
416 | 416 | return $cache->getUserParams($remoteId); |
417 | 417 | } |
418 | 418 | |
419 | - if(func_num_args() === 2) { |
|
419 | + if (func_num_args() === 2) { |
|
420 | 420 | return $cache->getUserParam($remoteId, $key); |
421 | 421 | } |
422 | 422 | |
@@ -440,10 +440,10 @@ discard block |
||
440 | 440 | try { |
441 | 441 | $output = $callback(); |
442 | 442 | } |
443 | - catch(\Exception $e) { |
|
443 | + catch (\Exception $e) { |
|
444 | 444 | DB::rollBack(); |
445 | 445 | |
446 | - if(is_null($fallback)) { |
|
446 | + if (is_null($fallback)) { |
|
447 | 447 | throw $e; |
448 | 448 | } |
449 | 449 |
@@ -85,13 +85,13 @@ discard block |
||
85 | 85 | */ |
86 | 86 | protected function runActionHandler(string $action) |
87 | 87 | { |
88 | - if(!in_array($action, $this->actions)) { |
|
88 | + if (!in_array($action, $this->actions)) { |
|
89 | 89 | throw new \InvalidArgumentException("Unknown action `{$action}` passed"); |
90 | 90 | } |
91 | 91 | |
92 | 92 | $actionHandler = 'handle' . Str::studly($action); |
93 | 93 | |
94 | - if(!method_exists($this, $actionHandler)) { |
|
94 | + if (!method_exists($this, $actionHandler)) { |
|
95 | 95 | throw new \InvalidArgumentException("Cannot find action handler `{$actionHandler}`"); |
96 | 96 | } |
97 | 97 | |
@@ -138,12 +138,12 @@ discard block |
||
138 | 138 | { |
139 | 139 | $users = $this->retrieveUsers(['id' => $this->ids], true); |
140 | 140 | |
141 | - if($users->isEmpty()) { |
|
141 | + if ($users->isEmpty()) { |
|
142 | 142 | $this->info('No users found.'); |
143 | 143 | return; |
144 | 144 | } |
145 | 145 | else { |
146 | - if(!$this->confirm('Do you want to restore ' . $users->count() . ' user(s)?')) { |
|
146 | + if (!$this->confirm('Do you want to restore ' . $users->count() . ' user(s)?')) { |
|
147 | 147 | return; |
148 | 148 | } |
149 | 149 | } |
@@ -154,7 +154,7 @@ discard block |
||
154 | 154 | |
155 | 155 | $this->info('User #' . $user->id . ' (' . $user->email . ') successfully restored.'); |
156 | 156 | } |
157 | - catch(\Exception $e) { |
|
157 | + catch (\Exception $e) { |
|
158 | 158 | $this->error('User #' . $user->id . ' (' . $user->email . ') cannot be restored. ' . $e->getMessage()); |
159 | 159 | } |
160 | 160 | } |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | $query->whereIn($column, $value); |
179 | 179 | } |
180 | 180 | |
181 | - if($onlyTrashed) { |
|
181 | + if ($onlyTrashed) { |
|
182 | 182 | $query->whereNotNull('deleted_at'); |
183 | 183 | } |
184 | 184 |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | { |
33 | 33 | $difference = $this->parseDump($path, $sharedKey, $importModes); |
34 | 34 | |
35 | - $foreigners = array_map(function (array $user) { |
|
35 | + $foreigners = array_map(function(array $user) { |
|
36 | 36 | return $this->createRemoteUserFromResponse($user); |
37 | 37 | }, $difference); |
38 | 38 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | */ |
56 | 56 | private function parseDump(string $filename, string $sharedKey, bool $importModes): array |
57 | 57 | { |
58 | - if(!file_exists($filename)) { |
|
58 | + if (!file_exists($filename)) { |
|
59 | 59 | throw new \InvalidArgumentException($filename . ' cannot be found'); |
60 | 60 | } |
61 | 61 | |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | // Then delete from a dump so we can proceed with decryption |
68 | 68 | $this->extractHeaders($payload); |
69 | 69 | |
70 | - if($importModes) { |
|
70 | + if ($importModes) { |
|
71 | 71 | $this->modes = Arr::get($this->importHeaders, 'modes', []); |
72 | 72 | } |
73 | 73 |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | */ |
159 | 159 | protected function parseResponse(array $response) |
160 | 160 | { |
161 | - $foreigners = array_map(function (array $user) { |
|
161 | + $foreigners = array_map(function(array $user) { |
|
162 | 162 | return $this->createRemoteUserFromResponse($user); |
163 | 163 | }, Arr::get($response, 'difference')); |
164 | 164 | |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | $action = $foreigner->getRemoteAction() |
199 | 199 | ); |
200 | 200 | } |
201 | - catch(\Slides\Connector\Auth\Exceptions\SyncException $e) { |
|
201 | + catch (\Slides\Connector\Auth\Exceptions\SyncException $e) { |
|
202 | 202 | \Illuminate\Support\Facades\Log::error( |
203 | 203 | "Cannot $action the user {$foreigner->getEmail()}: " . $e->getMessage() |
204 | 204 | ); |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | { |
364 | 364 | $output[] = $message; |
365 | 365 | |
366 | - if($this->outputCallback instanceof \Closure) { |
|
366 | + if ($this->outputCallback instanceof \Closure) { |
|
367 | 367 | call_user_func($this->outputCallback, $message); |
368 | 368 | } |
369 | 369 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | { |
30 | 30 | $handler = 'action' . Str::studly($action); |
31 | 31 | |
32 | - if(!method_exists($this, $handler)) { |
|
32 | + if (!method_exists($this, $handler)) { |
|
33 | 33 | throw new \Slides\Connector\Auth\Exceptions\SyncException("User action handler {$handler} cannot be found."); |
34 | 34 | } |
35 | 35 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | protected function actionCreate(RemoteUser $remote) |
49 | 49 | { |
50 | 50 | // If a user with the same email was found, we need to skip the process |
51 | - if(Auth::getProvider()->retrieveByCredentials(['email' => strtolower($remote->getEmail())])) { |
|
51 | + if (Auth::getProvider()->retrieveByCredentials(['email' => strtolower($remote->getEmail())])) { |
|
52 | 52 | return; |
53 | 53 | } |
54 | 54 | |
@@ -69,18 +69,18 @@ discard block |
||
69 | 69 | protected function actionUpdate(RemoteUser $remote) |
70 | 70 | { |
71 | 71 | // If a user with the same email cannot be found, we should skip the process |
72 | - if(!$local = Auth::getProvider()->retrieveByCredentials(['email' => $remote->getEmail()])) { |
|
72 | + if (!$local = Auth::getProvider()->retrieveByCredentials(['email' => $remote->getEmail()])) { |
|
73 | 73 | return; |
74 | 74 | } |
75 | 75 | |
76 | 76 | // If a local user was updated later than remote one, we should skip the process |
77 | 77 | // Since we have a latest one |
78 | - if($this->localNewerThanRemote($local, $remote)) { |
|
78 | + if ($this->localNewerThanRemote($local, $remote)) { |
|
79 | 79 | return; |
80 | 80 | } |
81 | 81 | |
82 | 82 | // If "password" mode is not enabled, we cannot update local passwords, so we simply resetting it |
83 | - if(!$this->hasMode(static::MODE_PASSWORDS)) { |
|
83 | + if (!$this->hasMode(static::MODE_PASSWORDS)) { |
|
84 | 84 | $remote->resetPassword(); |
85 | 85 | } |
86 | 86 | |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | */ |
104 | 104 | protected function actionDelete(RemoteUser $remote) |
105 | 105 | { |
106 | - if(!$local = Auth::getProvider()->retrieveByCredentials(['email' => $remote->getEmail()])) { |
|
106 | + if (!$local = Auth::getProvider()->retrieveByCredentials(['email' => $remote->getEmail()])) { |
|
107 | 107 | return; |
108 | 108 | } |
109 | 109 | |
@@ -122,15 +122,15 @@ discard block |
||
122 | 122 | */ |
123 | 123 | private function localNewerThanRemote(LocalUser $local, RemoteUser $remote) |
124 | 124 | { |
125 | - if(!$local->retrieveRemoteId()) { |
|
125 | + if (!$local->retrieveRemoteId()) { |
|
126 | 126 | return false; |
127 | 127 | } |
128 | 128 | |
129 | - if(!$remoteUpdated = $remote->getUpdated()) { |
|
129 | + if (!$remoteUpdated = $remote->getUpdated()) { |
|
130 | 130 | return false; |
131 | 131 | } |
132 | 132 | |
133 | - if(!$localUpdate = $local->retrieveUpdatedAt()) { |
|
133 | + if (!$localUpdate = $local->retrieveUpdatedAt()) { |
|
134 | 134 | return false; |
135 | 135 | } |
136 | 136 |
@@ -90,12 +90,12 @@ discard block |
||
90 | 90 | { |
91 | 91 | $response = $this->client->request('login', compact('email', 'password', 'remember')); |
92 | 92 | |
93 | - if(!$this->client->success(true)) { |
|
93 | + if (!$this->client->success(true)) { |
|
94 | 94 | $this->lastError = Arr::get($response, 'message'); |
95 | 95 | return false; |
96 | 96 | } |
97 | 97 | |
98 | - if(!$this->token = $this->client->getToken()) { |
|
98 | + if (!$this->token = $this->client->getToken()) { |
|
99 | 99 | return false; |
100 | 100 | } |
101 | 101 | |
@@ -122,11 +122,11 @@ discard block |
||
122 | 122 | { |
123 | 123 | $this->client->request('unsafeLogin', compact('email', 'remember')); |
124 | 124 | |
125 | - if(!$this->client->success()) { |
|
125 | + if (!$this->client->success()) { |
|
126 | 126 | return false; |
127 | 127 | } |
128 | 128 | |
129 | - if(!$this->token = $this->client->getToken()) { |
|
129 | + if (!$this->token = $this->client->getToken()) { |
|
130 | 130 | return false; |
131 | 131 | } |
132 | 132 | |
@@ -145,13 +145,13 @@ discard block |
||
145 | 145 | // If we've already retrieved the user for the current request we can just |
146 | 146 | // return it back immediately. We do not want to fetch the user data on |
147 | 147 | // every call to this method because that would be tremendously slow. |
148 | - if (! is_null($this->user)) { |
|
148 | + if (!is_null($this->user)) { |
|
149 | 149 | return $this->user; |
150 | 150 | } |
151 | 151 | |
152 | 152 | $user = null; |
153 | 153 | |
154 | - if($token = $this->token()) { |
|
154 | + if ($token = $this->token()) { |
|
155 | 155 | $user = $this->retrieveUserFromToken($token); |
156 | 156 | } |
157 | 157 | |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | */ |
166 | 166 | public function token() |
167 | 167 | { |
168 | - if($this->token) { |
|
168 | + if ($this->token) { |
|
169 | 169 | return $this->token; |
170 | 170 | } |
171 | 171 | |
@@ -214,13 +214,13 @@ discard block |
||
214 | 214 | { |
215 | 215 | $data = (array) \Firebase\JWT\JWT::decode($token, env('JWT_SECRET'), ['HS256']); |
216 | 216 | } |
217 | - catch(\RuntimeException $e) { |
|
217 | + catch (\RuntimeException $e) { |
|
218 | 218 | $this->logout(); |
219 | 219 | |
220 | 220 | return null; |
221 | 221 | } |
222 | 222 | |
223 | - if(!$userId = Arr::get($data, 'userId')) { |
|
223 | + if (!$userId = Arr::get($data, 'userId')) { |
|
224 | 224 | return null; |
225 | 225 | } |
226 | 226 |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | */ |
25 | 25 | public static function stringToArray(string $string = null, string $valueDelimiter = ':', string $itemDelimiter = ',') |
26 | 26 | { |
27 | - if(is_null($string)) { |
|
27 | + if (is_null($string)) { |
|
28 | 28 | return []; |
29 | 29 | } |
30 | 30 | |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | $key = Arr::get($item, 0); |
38 | 38 | $value = Arr::get($item, 1); |
39 | 39 | |
40 | - if(is_null($value)) { |
|
40 | + if (is_null($value)) { |
|
41 | 41 | $value = $key; |
42 | 42 | $key = $index; |
43 | 43 | } |