Completed
Push — master ( 4314d2...3ee107 )
by Artem
03:45
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
@@ -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,13 +136,13 @@  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()) {
145
+        if ($token = $this->token()) {
146 146
             $user = $this->retrieveUserFromToken($token);
147 147
         }
148 148
 
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
      */
157 157
     public function token()
158 158
     {
159
-        if($this->token) {
159
+        if ($this->token) {
160 160
             return $this->token;
161 161
         }
162 162
 
@@ -205,13 +205,13 @@  discard block
 block discarded – undo
205 205
         {
206 206
             $data = (array) \Firebase\JWT\JWT::decode($token, env('JWT_SECRET'), ['HS256']);
207 207
         }
208
-        catch(\RuntimeException $e) {
208
+        catch (\RuntimeException $e) {
209 209
             $this->logout();
210 210
 
211 211
             return null;
212 212
         }
213 213
 
214
-        if(!$userId = array_get($data, 'userId')) {
214
+        if (!$userId = array_get($data, 'userId')) {
215 215
             return null;
216 216
         }
217 217
 
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());
@@ -212,11 +212,11 @@  discard block
 block discarded – undo
212 212
      */
213 213
     public function request(string $name, array $parameters = []): array
214 214
     {
215
-        if(!$this->hasRequest($name)) {
215
+        if (!$this->hasRequest($name)) {
216 216
             throw new \InvalidArgumentException("Request `{$name}` is not supported");
217 217
         }
218 218
 
219
-        if(!method_exists($this, $name)) {
219
+        if (!method_exists($this, $name)) {
220 220
             throw new \InvalidArgumentException("Request `{$name}` listed but isn't implemented");
221 221
         }
222 222
 
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
      */
247 247
     public function success(bool $withStatus = false): bool
248 248
     {
249
-        if(!$this->response || $this->response->getStatusCode() !== 200) {
249
+        if (!$this->response || $this->response->getStatusCode() !== 200) {
250 250
             return false;
251 251
         }
252 252
 
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 
311 311
         $this->formatted = $decoded;
312 312
 
313
-        if($this->success()) {
313
+        if ($this->success()) {
314 314
            return $this->formatted;
315 315
         }
316 316
 
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
      */
335 335
     private function bearerToken()
336 336
     {
337
-        if(!$token = app('auth')->token()) {
337
+        if (!$token = app('auth')->token()) {
338 338
             return null;
339 339
         }
340 340
 
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
     public function bearerTokenHeader(): \Closure
350 350
     {
351 351
         return function(callable $handler) {
352
-            return function (\Psr\Http\Message\RequestInterface $request, array $options) use ($handler) {
352
+            return function(\Psr\Http\Message\RequestInterface $request, array $options) use ($handler) {
353 353
                 $request = $request->withHeader('Authorization', $this->bearerToken());
354 354
 
355 355
                 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   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
      */
81 81
     public function login(string $email, string $password, bool $remember = false)
82 82
     {
83
-        if($this->disabled()) {
83
+        if ($this->disabled()) {
84 84
             return $this->handleFallback('login', compact('email', 'password', 'remember'));
85 85
         }
86 86
 
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
      */
103 103
     public function unsafeLogin(string $email, bool $remember = false)
104 104
     {
105
-        if($this->disabled()) {
105
+        if ($this->disabled()) {
106 106
             return $this->handleFallback('unsafeLogin', compact('email', 'remember'));
107 107
         }
108 108
 
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
      */
119 119
     public function logout()
120 120
     {
121
-        if($this->disabled()) {
121
+        if ($this->disabled()) {
122 122
             return $this->handleFallback('logout');
123 123
         }
124 124
 
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
      */
140 140
     public function register(int $userId, string $name, string $email, string $password)
141 141
     {
142
-        if($this->disabled()) {
142
+        if ($this->disabled()) {
143 143
             return [];
144 144
         }
145 145
 
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
      */
158 158
     public function forgot(string $email)
159 159
     {
160
-        if($this->disabled()) {
160
+        if ($this->disabled()) {
161 161
             return $this->handleFallback('forgot', compact('email'));
162 162
         }
163 163
 
@@ -178,13 +178,13 @@  discard block
 block discarded – undo
178 178
      */
179 179
     public function validatePasswordResetToken(string $token, string $email)
180 180
     {
181
-        if($this->disabled()) {
181
+        if ($this->disabled()) {
182 182
             return $this->handleFallback('validateReset', compact('token', 'email'));
183 183
         }
184 184
 
185 185
         $response = $this->client->request('validateReset', compact('token', 'email'));
186 186
 
187
-        if(!$this->client->success(true)) {
187
+        if (!$this->client->success(true)) {
188 188
             return false;
189 189
         }
190 190
 
@@ -207,13 +207,13 @@  discard block
 block discarded – undo
207 207
     {
208 208
         $parameters = compact('token', 'email', 'password', 'confirmation');
209 209
 
210
-        if($this->disabled()) {
210
+        if ($this->disabled()) {
211 211
             return $this->handleFallback('resetPassword', $parameters);
212 212
         }
213 213
 
214 214
         $response = $this->client->request('reset', $parameters);
215 215
 
216
-        if(!$this->client->success(true)) {
216
+        if (!$this->client->success(true)) {
217 217
             return false;
218 218
         }
219 219
 
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
      */
233 233
     public function update(int $id, ?string $name, ?string $email, ?string $password)
234 234
     {
235
-        if($this->disabled()) {
235
+        if ($this->disabled()) {
236 236
             return false;
237 237
         }
238 238
 
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 
241 241
         $response = $this->client->request('update', compact('id', 'attributes'));
242 242
 
243
-        if(!$this->client->success(true)) {
243
+        if (!$this->client->success(true)) {
244 244
             return false;
245 245
         }
246 246
 
@@ -274,7 +274,7 @@  discard block
 block discarded – undo
274 274
     {
275 275
         $handler = camel_case(str_replace('.', ' ', $key));
276 276
 
277
-        if(!method_exists($this->handlersContainer, $handler)) {
277
+        if (!method_exists($this->handlersContainer, $handler)) {
278 278
             throw new \InvalidArgumentException("Handler `{$handler}` cannot be found");
279 279
         }
280 280
 
@@ -319,10 +319,10 @@  discard block
 block discarded – undo
319 319
         try {
320 320
             $output = $callback();
321 321
         }
322
-        catch(\Exception $e) {
322
+        catch (\Exception $e) {
323 323
             DB::rollBack();
324 324
 
325
-            if(is_null($fallback)) {
325
+            if (is_null($fallback)) {
326 326
                 throw $e;
327 327
             }
328 328
 
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.