Passed
Push — master ( cf4fbb...361e7c )
by Artem
02:40
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   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -82,11 +82,11 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Client.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -311,7 +311,7 @@
 block discarded – undo
311 311
         $this->formatted = $decoded;
312 312
 
313 313
         if($this->success()) {
314
-           return $this->formatted;
314
+            return $this->formatted;
315 315
         }
316 316
 
317 317
         $message = array_get($this->formatted, 'message');
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -61,15 +61,15 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.
src/AuthService.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -296,8 +296,7 @@
 block discarded – undo
296 296
 
297 297
         try {
298 298
             $output = $callback();
299
-        }
300
-        catch(\Exception $e) {
299
+        } catch(\Exception $e) {
301 300
             DB::rollBack();
302 301
 
303 302
             if(is_null($fallback)) {
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 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
 
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/ServiceProvider.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
      */
74 74
     protected function loadConsoleCommands()
75 75
     {
76
-        if(!$this->app->runningInConsole()) {
76
+        if (!$this->app->runningInConsole()) {
77 77
             return;
78 78
         }
79 79
 
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
     protected function loadGuards()
92 92
     {
93 93
         // Skip loading guards if an application running in the console
94
-        if($this->app->runningInConsole()) {
94
+        if ($this->app->runningInConsole()) {
95 95
             return;
96 96
         }
97 97
 
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
             $this->app['auth']->guard('authService')
100 100
         );
101 101
 
102
-        if(!$this->enabled()) {
102
+        if (!$this->enabled()) {
103 103
             $this->app['authService']->setFallbackGuard(
104 104
                 $this->app['auth']->guard('fallback')
105 105
             );
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
         });
137 137
 
138 138
         // Register the fallback driver if service is disabled
139
-        if(!$this->enabled()) {
139
+        if (!$this->enabled()) {
140 140
             $this->app['auth']->shouldUse('fallback');
141 141
         }
142 142
     }
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/Commands/SyncUsers.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -74,12 +74,12 @@  discard block
 block discarded – undo
74 74
             ->newQuery()
75 75
             ->get();
76 76
 
77
-        if($users->isEmpty()) {
77
+        if ($users->isEmpty()) {
78 78
             $this->info('No users found.');
79 79
             return;
80 80
         }
81 81
 
82
-        if(!$this->confirm('There are ' . $users->count() . ' users to sync. Continue?')) {
82
+        if (!$this->confirm('There are ' . $users->count() . ' users to sync. Continue?')) {
83 83
             return;
84 84
         }
85 85
 
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 
94 94
         $this->writeStats('Remote affection', array_keys($remoteStats), array_values($remoteStats));
95 95
 
96
-        if(!count($difference)) {
96
+        if (!count($difference)) {
97 97
             $this->info('There are no changes to apply locally.');
98 98
         }
99 99
         else {
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
         $email = $user->getEmail();
188 188
 
189 189
         // If a user already exists, skip the process
190
-        if(Auth::getProvider()->retrieveByCredentials(['email' => $email])) {
190
+        if (Auth::getProvider()->retrieveByCredentials(['email' => $email])) {
191 191
             $this->warn("User with email {$email} already exists, unable to create");
192 192
 
193 193
             return;
@@ -208,13 +208,13 @@  discard block
 block discarded – undo
208 208
         $email = $user->getEmail();
209 209
 
210 210
         // If a user doesn't exist, skip the process
211
-        if(!$model = Auth::getProvider()->retrieveByCredentials(['email' => $email])) {
211
+        if (!$model = Auth::getProvider()->retrieveByCredentials(['email' => $email])) {
212 212
             $this->warn("User with email {$email} doesn't exist, unable to update");
213 213
 
214 214
             return;
215 215
         }
216 216
 
217
-        if(!$this->passwords) {
217
+        if (!$this->passwords) {
218 218
             $user->resetPassword();
219 219
         }
220 220
 
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
         $email = $user->getEmail();
237 237
 
238 238
         // If a user doesn't exist, skip the process
239
-        if(!$model = Auth::getProvider()->retrieveByCredentials(['email' => $email])) {
239
+        if (!$model = Auth::getProvider()->retrieveByCredentials(['email' => $email])) {
240 240
             $this->warn("User with email {$email} doesn't exist, unable to delete");
241 241
 
242 242
             return;
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -95,8 +95,7 @@
 block discarded – undo
95 95
 
96 96
         if(!count($difference)) {
97 97
             $this->info('There are no changes to apply locally.');
98
-        }
99
-        else {
98
+        } else {
100 99
             $this->info('Remote changes detected, applying...');
101 100
 
102 101
             $localStats = $this->applyDifference($difference);
Please login to merge, or discard this patch.