| Conditions | 14 |
| Paths | 23 |
| Total Lines | 82 |
| Code Lines | 51 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 52 | public function handle() |
||
| 53 | { |
||
| 54 | $appid = $this->argument('appid'); |
||
| 55 | /** @var AppClient $appClient */ |
||
| 56 | $appClient = $this->validateAppId($appid); |
||
| 57 | $name = $appClient->name; |
||
| 58 | |||
| 59 | $options = $this->options(); |
||
| 60 | $options = Arr::where($options, function ($option) { |
||
| 61 | if ($option) { |
||
| 62 | return $option; |
||
| 63 | } |
||
| 64 | }); |
||
| 65 | |||
| 66 | // too many params |
||
| 67 | if (count($options) > 1) { |
||
| 68 | $this->error(self::MESSAGE_ERROR_PARAMS_MANY); |
||
| 69 | exit(); |
||
| 70 | } |
||
| 71 | |||
| 72 | // is trashed |
||
| 73 | if ($appClient->trashed()) { |
||
| 74 | $this->error(self::MESSAGE_ERROR_APP_TRASHED); |
||
| 75 | exit(); |
||
| 76 | } |
||
| 77 | |||
| 78 | if (Arr::has($options, 'activate')) { |
||
| 79 | // activate app |
||
| 80 | if ($appClient->active) { |
||
| 81 | $this->info('App "' . $name . '" is already active'); |
||
| 82 | exit(); |
||
| 83 | } |
||
| 84 | $appClient->active = AppClient::ACTIVATE; |
||
| 85 | $appClient->save(); |
||
| 86 | $this->info("Activate app succ, name: {$name}"); |
||
| 87 | |||
| 88 | } elseif (Arr::has($options, 'deactivate')) { |
||
| 89 | // deactivate app |
||
| 90 | if (!$appClient->active) { |
||
| 91 | $this->info('App "' . $name . '" is already deactivate'); |
||
| 92 | exit(); |
||
| 93 | } |
||
| 94 | $appClient->active = AppClient::DEACTIVATE; |
||
| 95 | $appClient->save(); |
||
| 96 | $this->info("Deactivate app succ, name: {$name}"); |
||
| 97 | |||
| 98 | } elseif (Arr::has($options, 'delete')) { |
||
| 99 | // delete app |
||
| 100 | $confirmMessage = "Are you sure you want to delete AppId:{$appid}, name:{$name} ?"; |
||
| 101 | |||
| 102 | if ($this->confirm($confirmMessage)) { |
||
| 103 | $appClient->delete(); |
||
| 104 | $this->info('Deleted app succ, name: ' . $name); |
||
| 105 | } |
||
| 106 | exit(); |
||
| 107 | } elseif (Arr::has($options, 'refresh')) { |
||
| 108 | // refresh this app secret |
||
| 109 | $confirmMessage = "Are you sure you want to refresh this app secret, AppId:{$appid}, name:{$name} ?"; |
||
| 110 | |||
| 111 | if ($this->confirm($confirmMessage)) { |
||
| 112 | $appClient->secret = AppClient::generateSecret(); |
||
| 113 | $appClient->save(); |
||
| 114 | $this->info('Refresh app secret succ, name: ' . $name); |
||
| 115 | } else { |
||
| 116 | exit(); |
||
| 117 | } |
||
| 118 | } |
||
| 119 | |||
| 120 | // get this record detail |
||
| 121 | $headers = ['AppName', 'AppId', 'Secret', 'Status', 'CreateAt']; |
||
| 122 | $status = $appClient->active ? 'active' : 'deactivated'; |
||
| 123 | $status = $appClient->trashed() ? 'deleted' : $status; |
||
| 124 | |||
| 125 | $rows = [[ |
||
| 126 | $appClient->name, |
||
| 127 | $appClient->appid, |
||
| 128 | $appClient->secret, |
||
| 129 | $status, |
||
| 130 | $appClient->created_at |
||
| 131 | ]]; |
||
| 132 | |||
| 133 | $this->table($headers, $rows); |
||
| 134 | } |
||
| 152 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths