@@ -43,11 +43,11 @@ discard block |
||
| 43 | 43 | |
| 44 | 44 | $syncer = new Syncer($locals = $this->syncingUsers(), $this->modes()); |
| 45 | 45 | |
| 46 | - if($locals->isEmpty()) { |
|
| 46 | + if ($locals->isEmpty()) { |
|
| 47 | 47 | $this->info('No local users found.'); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - if(!$this->confirm('There are ' . $locals->count() . ' local user(s) to export. Continue?', $this->option('no-interaction'))) { |
|
| 50 | + if (!$this->confirm('There are ' . $locals->count() . ' local user(s) to export. Continue?', $this->option('no-interaction'))) { |
|
| 51 | 51 | return; |
| 52 | 52 | } |
| 53 | 53 | |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | */ |
| 103 | 103 | private function syncingUsers() |
| 104 | 104 | { |
| 105 | - if(!count($ids = ConsoleHelper::stringToArray($this->option('users')))) { |
|
| 105 | + if (!count($ids = ConsoleHelper::stringToArray($this->option('users')))) { |
|
| 106 | 106 | return Syncer::retrieveLocals(); |
| 107 | 107 | } |
| 108 | 108 | |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | */ |
| 120 | 120 | private function filePath() |
| 121 | 121 | { |
| 122 | - if(!$path = $this->option('path')) { |
|
| 122 | + if (!$path = $this->option('path')) { |
|
| 123 | 123 | $path = storage_path('app'); |
| 124 | 124 | } |
| 125 | 125 | |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | */ |
| 40 | 40 | public function handle() |
| 41 | 41 | { |
| 42 | - if(!$key = $this->option('key')) { |
|
| 42 | + if (!$key = $this->option('key')) { |
|
| 43 | 43 | throw new \InvalidArgumentException('Encryption key must be passed.'); |
| 44 | 44 | } |
| 45 | 45 | |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | |
| 62 | 62 | $changes = $syncer->getForeignersCount(); |
| 63 | 63 | |
| 64 | - if(!$this->confirm('Apply ' . $changes . ' changes?', true)) { |
|
| 64 | + if (!$this->confirm('Apply ' . $changes . ' changes?', true)) { |
|
| 65 | 65 | return; |
| 66 | 66 | } |
| 67 | 67 | |
@@ -99,15 +99,15 @@ discard block |
||
| 99 | 99 | */ |
| 100 | 100 | protected function flushListeners() |
| 101 | 101 | { |
| 102 | - if(class_exists('\App\Http\Models\User')) { |
|
| 102 | + if (class_exists('\App\Http\Models\User')) { |
|
| 103 | 103 | \App\Http\Models\User::flushEventListeners(); |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - if(class_exists('App\Http\Models\CustomerProfile')) { |
|
| 106 | + if (class_exists('App\Http\Models\CustomerProfile')) { |
|
| 107 | 107 | \App\Http\Models\CustomerProfile::flushEventListeners(); |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - if(class_exists('App\Modules\Billing\Models\Account::class')) { |
|
| 110 | + if (class_exists('App\Modules\Billing\Models\Account::class')) { |
|
| 111 | 111 | \App\Modules\Billing\Models\Account::flushEventListeners(); |
| 112 | 112 | } |
| 113 | 113 | } |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | */ |
| 23 | 23 | public static function stringToArray(string $string = null, string $valueDelimiter = ':', string $itemDelimiter = ',') |
| 24 | 24 | { |
| 25 | - if(is_null($string)) { |
|
| 25 | + if (is_null($string)) { |
|
| 26 | 26 | return []; |
| 27 | 27 | } |
| 28 | 28 | |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | $key = array_get($item, 0); |
| 36 | 36 | $value = array_get($item, 1); |
| 37 | 37 | |
| 38 | - if(is_null($value)) { |
|
| 38 | + if (is_null($value)) { |
|
| 39 | 39 | $value = $key; |
| 40 | 40 | $key = $index; |
| 41 | 41 | } |
@@ -66,11 +66,11 @@ |
||
| 66 | 66 | |
| 67 | 67 | $syncer = new Syncer($locals = $this->syncingUsers(), $this->modes()); |
| 68 | 68 | |
| 69 | - if($locals->isEmpty()) { |
|
| 69 | + if ($locals->isEmpty()) { |
|
| 70 | 70 | $this->info('No local users found.'); |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - if(!$this->confirm('There are ' . $locals->count() . ' local user(s) to sync. Continue?', $this->option('no-interaction'))) { |
|
| 73 | + if (!$this->confirm('There are ' . $locals->count() . ' local user(s) to sync. Continue?', $this->option('no-interaction'))) { |
|
| 74 | 74 | return; |
| 75 | 75 | } |
| 76 | 76 | |
@@ -100,7 +100,7 @@ |
||
| 100 | 100 | */ |
| 101 | 101 | public static function deleteEmail(string $email, int $index): string |
| 102 | 102 | { |
| 103 | - if(strpos($email, ".{$index}.deleted" !== false)) { |
|
| 103 | + if (strpos($email, ".{$index}.deleted" !== false)) { |
|
| 104 | 104 | return $email; |
| 105 | 105 | } |
| 106 | 106 | |
@@ -140,8 +140,7 @@ discard block |
||
| 140 | 140 | if($users->isEmpty()) { |
| 141 | 141 | $this->info('No users found.'); |
| 142 | 142 | return; |
| 143 | - } |
|
| 144 | - else { |
|
| 143 | + } else { |
|
| 145 | 144 | if(!$this->confirm('Do you want to restore ' . $users->count() . ' user(s)?')) { |
| 146 | 145 | return; |
| 147 | 146 | } |
@@ -152,8 +151,7 @@ discard block |
||
| 152 | 151 | $this->authService->handle('restore', ['user' => $user]); |
| 153 | 152 | |
| 154 | 153 | $this->info('User #' . $user->id . ' (' . $user->email . ') successfully restored.'); |
| 155 | - } |
|
| 156 | - catch(\Exception $e) { |
|
| 154 | + } catch(\Exception $e) { |
|
| 157 | 155 | $this->error('User #' . $user->id . ' (' . $user->email . ') cannot be restored. ' . $e->getMessage()); |
| 158 | 156 | } |
| 159 | 157 | } |
@@ -84,13 +84,13 @@ discard block |
||
| 84 | 84 | */ |
| 85 | 85 | protected function runActionHandler(string $action) |
| 86 | 86 | { |
| 87 | - if(!in_array($action, $this->actions)) { |
|
| 87 | + if (!in_array($action, $this->actions)) { |
|
| 88 | 88 | throw new \InvalidArgumentException("Unknown action `{$action}` passed"); |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | $actionHandler = 'handle' . studly_case($action); |
| 92 | 92 | |
| 93 | - if(!method_exists($this, $actionHandler)) { |
|
| 93 | + if (!method_exists($this, $actionHandler)) { |
|
| 94 | 94 | throw new \InvalidArgumentException("Cannot find action handler `{$actionHandler}`"); |
| 95 | 95 | } |
| 96 | 96 | |
@@ -137,12 +137,12 @@ discard block |
||
| 137 | 137 | { |
| 138 | 138 | $users = $this->retrieveUsers(['id' => $this->ids], true); |
| 139 | 139 | |
| 140 | - if($users->isEmpty()) { |
|
| 140 | + if ($users->isEmpty()) { |
|
| 141 | 141 | $this->info('No users found.'); |
| 142 | 142 | return; |
| 143 | 143 | } |
| 144 | 144 | else { |
| 145 | - if(!$this->confirm('Do you want to restore ' . $users->count() . ' user(s)?')) { |
|
| 145 | + if (!$this->confirm('Do you want to restore ' . $users->count() . ' user(s)?')) { |
|
| 146 | 146 | return; |
| 147 | 147 | } |
| 148 | 148 | } |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | |
| 154 | 154 | $this->info('User #' . $user->id . ' (' . $user->email . ') successfully restored.'); |
| 155 | 155 | } |
| 156 | - catch(\Exception $e) { |
|
| 156 | + catch (\Exception $e) { |
|
| 157 | 157 | $this->error('User #' . $user->id . ' (' . $user->email . ') cannot be restored. ' . $e->getMessage()); |
| 158 | 158 | } |
| 159 | 159 | } |
@@ -177,7 +177,7 @@ discard block |
||
| 177 | 177 | $query->whereIn($column, $value); |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - if($onlyTrashed) { |
|
| 180 | + if ($onlyTrashed) { |
|
| 181 | 181 | $query->whereNotNull('deleted_at'); |
| 182 | 182 | } |
| 183 | 183 | |
@@ -23,10 +23,10 @@ |
||
| 23 | 23 | $keys = array_map('strtolower', $keys); |
| 24 | 24 | |
| 25 | 25 | foreach ($input as $key => $value) { |
| 26 | - if(is_array($value)) { |
|
| 26 | + if (is_array($value)) { |
|
| 27 | 27 | $input[$key] = static::replaceValuesByMatchingKeys($value, $keys, $replacement); |
| 28 | 28 | } |
| 29 | - elseif(is_string($key) && in_array(strtolower($key), $keys)) { |
|
| 29 | + elseif (is_string($key) && in_array(strtolower($key), $keys)) { |
|
| 30 | 30 | $input[$key] = $replacement instanceof \Closure |
| 31 | 31 | ? $replacement($key, $value) |
| 32 | 32 | : $replacement; |
@@ -25,8 +25,7 @@ |
||
| 25 | 25 | foreach ($input as $key => $value) { |
| 26 | 26 | if(is_array($value)) { |
| 27 | 27 | $input[$key] = static::replaceValuesByMatchingKeys($value, $keys, $replacement); |
| 28 | - } |
|
| 29 | - elseif(is_string($key) && in_array(strtolower($key), $keys)) { |
|
| 28 | + } elseif(is_string($key) && in_array(strtolower($key), $keys)) { |
|
| 30 | 29 | $input[$key] = $replacement instanceof \Closure |
| 31 | 30 | ? $replacement($key, $value) |
| 32 | 31 | : $replacement; |
@@ -380,7 +380,7 @@ |
||
| 380 | 380 | $this->log(null, $decoded ?? []); |
| 381 | 381 | |
| 382 | 382 | if($this->success()) { |
| 383 | - return $this->formatted; |
|
| 383 | + return $this->formatted; |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | $message = array_get($this->formatted, 'message'); |
@@ -64,15 +64,15 @@ discard block |
||
| 64 | 64 | */ |
| 65 | 65 | protected function boot() |
| 66 | 66 | { |
| 67 | - if(!$publicKey = $this->credential('public')) { |
|
| 67 | + if (!$publicKey = $this->credential('public')) { |
|
| 68 | 68 | throw new \InvalidArgumentException('Public key must be defined'); |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - if(!$secretKey = $this->credential('secret')) { |
|
| 71 | + if (!$secretKey = $this->credential('secret')) { |
|
| 72 | 72 | throw new \InvalidArgumentException('Secret key must be defined'); |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - if(!$this->client) { |
|
| 75 | + if (!$this->client) { |
|
| 76 | 76 | $handler = new \GuzzleHttp\HandlerStack(); |
| 77 | 77 | $handler->setHandler(new \GuzzleHttp\Handler\CurlHandler()); |
| 78 | 78 | $handler->push($this->bearerTokenHeader()); |
@@ -275,11 +275,11 @@ discard block |
||
| 275 | 275 | */ |
| 276 | 276 | public function request(string $name, array $parameters = []): array |
| 277 | 277 | { |
| 278 | - if(!$this->hasRequest($name)) { |
|
| 278 | + if (!$this->hasRequest($name)) { |
|
| 279 | 279 | throw new \InvalidArgumentException("Request `{$name}` is not supported"); |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | - if(!method_exists($this, $name)) { |
|
| 282 | + if (!method_exists($this, $name)) { |
|
| 283 | 283 | throw new \InvalidArgumentException("Request `{$name}` listed but is not implemented"); |
| 284 | 284 | } |
| 285 | 285 | |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | */ |
| 312 | 312 | public function success(bool $withStatus = false): bool |
| 313 | 313 | { |
| 314 | - if(!$this->response || $this->response->getStatusCode() !== 200) { |
|
| 314 | + if (!$this->response || $this->response->getStatusCode() !== 200) { |
|
| 315 | 315 | return false; |
| 316 | 316 | } |
| 317 | 317 | |
@@ -379,7 +379,7 @@ discard block |
||
| 379 | 379 | |
| 380 | 380 | $this->log(null, $decoded ?? []); |
| 381 | 381 | |
| 382 | - if($this->success()) { |
|
| 382 | + if ($this->success()) { |
|
| 383 | 383 | return $this->formatted; |
| 384 | 384 | } |
| 385 | 385 | |
@@ -407,7 +407,7 @@ discard block |
||
| 407 | 407 | */ |
| 408 | 408 | private function bearerToken() |
| 409 | 409 | { |
| 410 | - if(!$token = app('auth')->token()) { |
|
| 410 | + if (!$token = app('auth')->token()) { |
|
| 411 | 411 | return null; |
| 412 | 412 | } |
| 413 | 413 | |
@@ -422,7 +422,7 @@ discard block |
||
| 422 | 422 | public function bearerTokenHeader(): \Closure |
| 423 | 423 | { |
| 424 | 424 | return function(callable $handler) { |
| 425 | - return function (\Psr\Http\Message\RequestInterface $request, array $options) use ($handler) { |
|
| 425 | + return function(\Psr\Http\Message\RequestInterface $request, array $options) use ($handler) { |
|
| 426 | 426 | $request = $request->withHeader('Authorization', $this->bearerToken()); |
| 427 | 427 | |
| 428 | 428 | return $handler($request, $options); |
@@ -29,20 +29,20 @@ |
||
| 29 | 29 | */ |
| 30 | 30 | public function handle(string $key, array $payload) |
| 31 | 31 | { |
| 32 | - if(!$this->has($key)) { |
|
| 32 | + if (!$this->has($key)) { |
|
| 33 | 33 | throw new WebhookException("Webhook with key \"{$key}\" cannot be found."); |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | $webhook = $this->instantiate($key); |
| 37 | 37 | |
| 38 | - if(!$webhook->validate($payload)) { |
|
| 38 | + if (!$webhook->validate($payload)) { |
|
| 39 | 39 | throw new WebhookValidationException($webhook->getValidator()); |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | try { |
| 43 | 43 | return $webhook->handle($payload); |
| 44 | 44 | } |
| 45 | - catch(\Exception $e) { |
|
| 45 | + catch (\Exception $e) { |
|
| 46 | 46 | throw new WebhookException(get_class($webhook) . ': ' . $e->getMessage()); |
| 47 | 47 | } |
| 48 | 48 | } |
@@ -41,8 +41,7 @@ |
||
| 41 | 41 | |
| 42 | 42 | try { |
| 43 | 43 | return $webhook->handle($payload); |
| 44 | - } |
|
| 45 | - catch(\Exception $e) { |
|
| 44 | + } catch(\Exception $e) { |
|
| 46 | 45 | throw new WebhookException(get_class($webhook) . ': ' . $e->getMessage()); |
| 47 | 46 | } |
| 48 | 47 | } |