Completed
Pull Request — master (#6)
by
unknown
03:48 queued 10s
created
src/TokenGuard.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -171,8 +171,7 @@
 block discarded – undo
171 171
         try
172 172
         {
173 173
             $data = (array) \Firebase\JWT\JWT::decode($token, env('JWT_SECRET'), ['HS256']);
174
-        }
175
-        catch(\RuntimeException $e) {
174
+        } catch(\RuntimeException $e) {
176 175
             $this->logout();
177 176
 
178 177
             return null;
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -89,12 +89,12 @@  discard block
 block discarded – undo
89 89
     {
90 90
         $response = $this->client->request('login', compact('email', 'password', 'remember'));
91 91
 
92
-        if(!$this->client->success(true)) {
92
+        if (!$this->client->success(true)) {
93 93
             $this->lastError = array_get($response, 'message');
94 94
             return false;
95 95
         }
96 96
 
97
-        if(!$this->token = $this->client->getToken()) {
97
+        if (!$this->token = $this->client->getToken()) {
98 98
             return false;
99 99
         }
100 100
 
@@ -121,11 +121,11 @@  discard block
 block discarded – undo
121 121
     {
122 122
         $this->client->request('unsafeLogin', compact('email', 'remember'));
123 123
 
124
-        if(!$this->client->success()) {
124
+        if (!$this->client->success()) {
125 125
             return false;
126 126
         }
127 127
 
128
-        if(!$this->token = $this->client->getToken()) {
128
+        if (!$this->token = $this->client->getToken()) {
129 129
             return false;
130 130
         }
131 131
 
@@ -144,13 +144,13 @@  discard block
 block discarded – undo
144 144
         // If we've already retrieved the user for the current request we can just
145 145
         // return it back immediately. We do not want to fetch the user data on
146 146
         // every call to this method because that would be tremendously slow.
147
-        if (! is_null($this->user)) {
147
+        if (!is_null($this->user)) {
148 148
             return $this->user;
149 149
         }
150 150
 
151 151
         $user = null;
152 152
 
153
-        if($token = $this->token()) {
153
+        if ($token = $this->token()) {
154 154
             $user = $this->retrieveUserFromToken($token);
155 155
         }
156 156
 
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
      */
165 165
     public function token()
166 166
     {
167
-        if($this->token) {
167
+        if ($this->token) {
168 168
             return $this->token;
169 169
         }
170 170
 
@@ -213,13 +213,13 @@  discard block
 block discarded – undo
213 213
         {
214 214
             $data = (array) \Firebase\JWT\JWT::decode($token, env('JWT_SECRET'), ['HS256']);
215 215
         }
216
-        catch(\RuntimeException $e) {
216
+        catch (\RuntimeException $e) {
217 217
             $this->logout();
218 218
 
219 219
             return null;
220 220
         }
221 221
 
222
-        if(!$userId = array_get($data, 'userId')) {
222
+        if (!$userId = array_get($data, 'userId')) {
223 223
             return null;
224 224
         }
225 225
 
Please login to merge, or discard this patch.
src/Exceptions/ValidationException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@
 block discarded – undo
46 46
         $messages = [];
47 47
 
48 48
         foreach (json_decode($message, true) as $property => $attributeMessages) {
49
-            if(in_array($property, static::$attributeHides)) {
49
+            if (in_array($property, static::$attributeHides)) {
50 50
                 continue;
51 51
             }
52 52
 
Please login to merge, or discard this patch.
src/Concerns/ResetsPasswords.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
      */
29 29
     public function showResetForm(string $token, string $email)
30 30
     {
31
-        if(!$email = AuthService::validatePasswordResetToken($token, $email)) {
31
+        if (!$email = AuthService::validatePasswordResetToken($token, $email)) {
32 32
             throw new \Symfony\Component\HttpKernel\Exception\NotFoundHttpException();
33 33
         }
34 34
 
@@ -48,13 +48,13 @@  discard block
 block discarded – undo
48 48
     {
49 49
         $this->validate($request, $this->rules(), $this->validationErrorMessages());
50 50
 
51
-        if(AuthService::resetPassword(
51
+        if (AuthService::resetPassword(
52 52
             $request->input('token'),
53 53
             $email = $request->input('email'),
54 54
             $password = $request->input('password'),
55 55
             $request->input('password_confirmation')
56 56
         )) {
57
-            if(AuthService::login($email, $password)) {
57
+            if (AuthService::login($email, $password)) {
58 58
                 return $this->sendResetResponse(PasswordBroker::PASSWORD_RESET);
59 59
             }
60 60
         }
Please login to merge, or discard this patch.
src/AuthService.php 2 patches
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -262,8 +262,7 @@  discard block
 block discarded – undo
262 262
 
263 263
         try {
264 264
             $response = $this->client->request('me');
265
-        }
266
-        catch(\Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException $e) {
265
+        } catch(\Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException $e) {
267 266
             return null;
268 267
         }
269 268
 
@@ -345,8 +344,7 @@  discard block
 block discarded – undo
345 344
 
346 345
         try {
347 346
             $output = $callback();
348
-        }
349
-        catch(\Exception $e) {
347
+        } catch(\Exception $e) {
350 348
             DB::rollBack();
351 349
 
352 350
             if(is_null($fallback)) {
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
      */
142 142
     public function register(int $userId, string $name, string $email, string $password, string $country)
143 143
     {
144
-        if($this->disabled()) {
144
+        if ($this->disabled()) {
145 145
             return [];
146 146
         }
147 147
 
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
      */
160 160
     public function forgot(string $email)
161 161
     {
162
-        if($this->disabled()) {
162
+        if ($this->disabled()) {
163 163
             return $this->handleFallback('forgot', compact('email'));
164 164
         }
165 165
 
@@ -180,13 +180,13 @@  discard block
 block discarded – undo
180 180
      */
181 181
     public function validatePasswordResetToken(string $token, string $email)
182 182
     {
183
-        if($this->disabled()) {
183
+        if ($this->disabled()) {
184 184
             return $this->handleFallback('validateReset', compact('token', 'email'));
185 185
         }
186 186
 
187 187
         $response = $this->client->request('validateReset', compact('token', 'email'));
188 188
 
189
-        if(!$this->client->success(true)) {
189
+        if (!$this->client->success(true)) {
190 190
             return false;
191 191
         }
192 192
 
@@ -209,13 +209,13 @@  discard block
 block discarded – undo
209 209
     {
210 210
         $parameters = compact('token', 'email', 'password', 'confirmation');
211 211
 
212
-        if($this->disabled()) {
212
+        if ($this->disabled()) {
213 213
             return $this->handleFallback('resetPassword', $parameters);
214 214
         }
215 215
 
216 216
         $response = $this->client->request('reset', $parameters);
217 217
 
218
-        if(!$this->client->success(true)) {
218
+        if (!$this->client->success(true)) {
219 219
             return false;
220 220
         }
221 221
 
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
      */
236 236
     public function update(int $id, ?string $name, ?string $email, ?string $password, ?string $country)
237 237
     {
238
-        if($this->disabled()) {
238
+        if ($this->disabled()) {
239 239
             return false;
240 240
         }
241 241
 
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 
244 244
         $response = $this->client->request('update', compact('id', 'attributes'));
245 245
 
246
-        if(!$this->client->success(true)) {
246
+        if (!$this->client->success(true)) {
247 247
             return false;
248 248
         }
249 249
 
@@ -259,13 +259,13 @@  discard block
 block discarded – undo
259 259
      */
260 260
     public function delete(int $id)
261 261
     {
262
-        if($this->disabled()) {
262
+        if ($this->disabled()) {
263 263
             return false;
264 264
         }
265 265
 
266 266
         $response = $this->client->request('delete', compact('id'));
267 267
 
268
-        if(!$this->client->success(true)) {
268
+        if (!$this->client->success(true)) {
269 269
             return false;
270 270
         }
271 271
 
@@ -281,13 +281,13 @@  discard block
 block discarded – undo
281 281
      */
282 282
     public function restore(int $id)
283 283
     {
284
-        if($this->disabled()) {
284
+        if ($this->disabled()) {
285 285
             return false;
286 286
         }
287 287
 
288 288
         $response = $this->client->request('restore', compact('id'));
289 289
 
290
-        if(!$this->client->success(true)) {
290
+        if (!$this->client->success(true)) {
291 291
             return false;
292 292
         }
293 293
 
@@ -301,18 +301,18 @@  discard block
 block discarded – undo
301 301
      */
302 302
     public function retrieveByToken()
303 303
     {
304
-        if($this->disabled()) {
304
+        if ($this->disabled()) {
305 305
             return null;
306 306
         }
307 307
 
308 308
         try {
309 309
             $response = $this->client->request('me');
310 310
         }
311
-        catch(\Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException $e) {
311
+        catch (\Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException $e) {
312 312
             return null;
313 313
         }
314 314
 
315
-        if(!$this->client->success(true)) {
315
+        if (!$this->client->success(true)) {
316 316
             return null;
317 317
         }
318 318
 
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
     {
347 347
         $handler = camel_case(str_replace('.', ' ', $key));
348 348
 
349
-        if(!method_exists($this->handlersContainer, $handler)) {
349
+        if (!method_exists($this->handlersContainer, $handler)) {
350 350
             throw new \InvalidArgumentException("Handler `{$handler}` cannot be found");
351 351
         }
352 352
 
@@ -386,11 +386,11 @@  discard block
 block discarded – undo
386 386
     {
387 387
         $cache = new Cache();
388 388
 
389
-        if(!func_num_args()) {
389
+        if (!func_num_args()) {
390 390
             return $cache;
391 391
         }
392 392
 
393
-        if(func_num_args() === 1) {
393
+        if (func_num_args() === 1) {
394 394
             return $cache->get($key);
395 395
         }
396 396
 
@@ -410,11 +410,11 @@  discard block
 block discarded – undo
410 410
     {
411 411
         $cache = new Cache();
412 412
 
413
-        if(func_num_args() === 1) {
413
+        if (func_num_args() === 1) {
414 414
             return $cache->getUserParams($remoteId);
415 415
         }
416 416
 
417
-        if(func_num_args() === 2) {
417
+        if (func_num_args() === 2) {
418 418
             return $cache->getUserParam($remoteId, $key);
419 419
         }
420 420
 
@@ -438,10 +438,10 @@  discard block
 block discarded – undo
438 438
         try {
439 439
             $output = $callback();
440 440
         }
441
-        catch(\Exception $e) {
441
+        catch (\Exception $e) {
442 442
             DB::rollBack();
443 443
 
444
-            if(is_null($fallback)) {
444
+            if (is_null($fallback)) {
445 445
                 throw $e;
446 446
             }
447 447
 
Please login to merge, or discard this patch.
src/Sync/HandlesActions.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
     {
29 29
         $handler = 'action' . studly_case($action);
30 30
 
31
-        if(!method_exists($this, $handler)) {
31
+        if (!method_exists($this, $handler)) {
32 32
             throw new \Slides\Connector\Auth\Exceptions\SyncException("User action handler {$handler} cannot be found.");
33 33
         }
34 34
 
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
     protected function actionCreate(RemoteUser $remote)
46 46
     {
47 47
         // If a user with the same email was found, we need to skip the process
48
-        if(Auth::getProvider()->retrieveByCredentials(['email' => strtolower($remote->getEmail())])) {
48
+        if (Auth::getProvider()->retrieveByCredentials(['email' => strtolower($remote->getEmail())])) {
49 49
             return;
50 50
         }
51 51
 
@@ -64,18 +64,18 @@  discard block
 block discarded – undo
64 64
     protected function actionUpdate(RemoteUser $remote)
65 65
     {
66 66
         // If a user with the same email cannot be found, we should skip the process
67
-        if(!$local = Auth::getProvider()->retrieveByCredentials(['email' => $remote->getEmail()])) {
67
+        if (!$local = Auth::getProvider()->retrieveByCredentials(['email' => $remote->getEmail()])) {
68 68
             return;
69 69
         }
70 70
 
71 71
         // If a local user was updated later than remote one, we should skip the process
72 72
         // Since we have a latest one
73
-        if($this->localNewerThanRemote($local, $remote)) {
73
+        if ($this->localNewerThanRemote($local, $remote)) {
74 74
             return;
75 75
         }
76 76
 
77 77
         // If "password" mode is not enabled, we cannot update local passwords, so we simply resetting it
78
-        if(!$this->hasMode(static::MODE_PASSWORDS)) {
78
+        if (!$this->hasMode(static::MODE_PASSWORDS)) {
79 79
             $remote->resetPassword();
80 80
         }
81 81
 
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
      */
97 97
     protected function actionDelete(RemoteUser $remote)
98 98
     {
99
-        if(!$local = Auth::getProvider()->retrieveByCredentials(['email' => $remote->getEmail()])) {
99
+        if (!$local = Auth::getProvider()->retrieveByCredentials(['email' => $remote->getEmail()])) {
100 100
             return;
101 101
         }
102 102
 
@@ -115,15 +115,15 @@  discard block
 block discarded – undo
115 115
      */
116 116
     private function localNewerThanRemote(LocalUser $local, RemoteUser $remote)
117 117
     {
118
-        if(!$local->retrieveRemoteId()) {
118
+        if (!$local->retrieveRemoteId()) {
119 119
             return false;
120 120
         }
121 121
 
122
-        if(!$remoteUpdated = $remote->getUpdated()) {
122
+        if (!$remoteUpdated = $remote->getUpdated()) {
123 123
             return false;
124 124
         }
125 125
 
126
-        if(!$localUpdate = $local->retrieveUpdatedAt()) {
126
+        if (!$localUpdate = $local->retrieveUpdatedAt()) {
127 127
             return false;
128 128
         }
129 129
 
Please login to merge, or discard this patch.
src/Sync/ImportsUsers.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
     {
32 32
         $difference = $this->parseDump($path, $sharedKey, $importModes);
33 33
 
34
-        $foreigners = array_map(function (array $user) {
34
+        $foreigners = array_map(function(array $user) {
35 35
             return $this->createRemoteUserFromResponse($user);
36 36
         }, $difference);
37 37
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
      */
55 55
     private function parseDump(string $filename, string $sharedKey, bool $importModes): array
56 56
     {
57
-        if(!file_exists($filename)) {
57
+        if (!file_exists($filename)) {
58 58
             throw new \InvalidArgumentException($filename . ' cannot be found');
59 59
         }
60 60
 
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
         // Then delete from a dump so we can proceed with decryption
67 67
         $this->extractHeaders($payload);
68 68
 
69
-        if($importModes) {
69
+        if ($importModes) {
70 70
             $this->modes = array_get($this->importHeaders, 'modes', []);
71 71
         }
72 72
 
Please login to merge, or discard this patch.
src/Sync/ExportsUsers.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@
 block discarded – undo
54 54
      */
55 55
     public function getEncryptionKey()
56 56
     {
57
-        if(!$this->encryptionKey) {
57
+        if (!$this->encryptionKey) {
58 58
             return null;
59 59
         }
60 60
 
Please login to merge, or discard this patch.
src/Sync/Syncer.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
      */
158 158
     protected function parseResponse(array $response)
159 159
     {
160
-        $foreigners = array_map(function (array $user) {
160
+        $foreigners = array_map(function(array $user) {
161 161
             return $this->createRemoteUserFromResponse($user);
162 162
         }, array_get($response, 'difference'));
163 163
 
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
                     $action = $foreigner->getRemoteAction()
198 198
                 );
199 199
             }
200
-            catch(\Slides\Connector\Auth\Exceptions\SyncException $e) {
200
+            catch (\Slides\Connector\Auth\Exceptions\SyncException $e) {
201 201
                 \Illuminate\Support\Facades\Log::error(
202 202
                     "Cannot $action the user {$foreigner->getEmail()}: " . $e->getMessage()
203 203
                 );
@@ -358,7 +358,7 @@  discard block
 block discarded – undo
358 358
     {
359 359
         $output[] = $message;
360 360
 
361
-        if($this->outputCallback instanceof \Closure) {
361
+        if ($this->outputCallback instanceof \Closure) {
362 362
             call_user_func($this->outputCallback, $message);
363 363
         }
364 364
     }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -196,8 +196,7 @@
 block discarded – undo
196 196
                     $foreigner,
197 197
                     $action = $foreigner->getRemoteAction()
198 198
                 );
199
-            }
200
-            catch(\Slides\Connector\Auth\Exceptions\SyncException $e) {
199
+            } catch(\Slides\Connector\Auth\Exceptions\SyncException $e) {
201 200
                 \Illuminate\Support\Facades\Log::error(
202 201
                     "Cannot $action the user {$foreigner->getEmail()}: " . $e->getMessage()
203 202
                 );
Please login to merge, or discard this patch.
src/Http/routes.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,6 +2,6 @@
 block discarded – undo
2 2
 
3 3
 use Illuminate\Support\Facades\Route;
4 4
 
5
-Route::group(['namespace' => 'Slides\Connector\Auth\Http\Controllers'], function () {
5
+Route::group(['namespace' => 'Slides\Connector\Auth\Http\Controllers'], function() {
6 6
     Route::post('connector/webhook/{key}', 'WebhookController');
7 7
 });
8 8
\ No newline at end of file
Please login to merge, or discard this patch.