| Conditions | 7 |
| Paths | 21 |
| Total Lines | 51 |
| Code Lines | 31 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 109 | protected function doExecute(IResponse $response) |
||
| 110 | { |
||
| 111 | $identifier = $this->getArgumentValue(static::ARGUMENT_IDENTIFIER); |
||
| 112 | $dryRun = $this->getOptionValue(static::OPTION_DRY_RUN); |
||
| 113 | |||
| 114 | try { |
||
| 115 | /** @var ApiClient $apiClient */ |
||
| 116 | $apiClient = $this->apiClientRepo->getById($identifier); |
||
| 117 | if (!$apiClient) { |
||
| 118 | $response->writeln(sprintf('<fatal>API client not found</fatal>')); |
||
| 119 | |||
| 120 | return; |
||
| 121 | } |
||
| 122 | |||
| 123 | $adminResources = $apiClient->getAdminResources(); |
||
| 124 | |||
| 125 | $rawSecret = $this->passwordGenerator->generatePassword(); |
||
| 126 | $preparedPassword = $this->crypto->prepareSecret($rawSecret); |
||
| 127 | $packedPassword = $this->crypto->hashCrypt($preparedPassword); |
||
| 128 | |||
| 129 | $apiClient->setSecret($packedPassword); |
||
| 130 | } catch (\Exception $e) { |
||
| 131 | if ($e->getPrevious()) { |
||
| 132 | $response->writeln(sprintf('<error>%s</error>', $e->getPrevious()->getMessage())); |
||
| 133 | } |
||
| 134 | $response->writeln(sprintf('<fatal>%s</fatal>', $e->getMessage())); |
||
| 135 | |||
| 136 | return; |
||
| 137 | } |
||
| 138 | |||
| 139 | if ($dryRun) { |
||
| 140 | $this->unitOfWork->dispose(); |
||
| 141 | $response->writeln(static::COMMAND_DRY_RUN_MESSAGE); |
||
| 142 | |||
| 143 | return; |
||
| 144 | } |
||
| 145 | |||
| 146 | try { |
||
| 147 | $this->unitOfWork->commit(); |
||
| 148 | $this->cacheManager->clearAll(); |
||
| 149 | } catch (\Exception $e) { |
||
| 150 | if ($e->getPrevious()) { |
||
| 151 | $response->writeln(sprintf('<error>%s</error>', $e->getPrevious()->getMessage())); |
||
| 152 | } |
||
| 153 | $response->writeln(sprintf('<fatal>%s</fatal>', $e->getMessage())); |
||
| 154 | |||
| 155 | return; |
||
| 156 | } |
||
| 157 | |||
| 158 | $response->writeln(sprintf(static::RESPONSE_SECRET, $rawSecret)); |
||
| 159 | $response->writeln(static::COMMAND_SUCCESS); |
||
| 160 | } |
||
| 162 |
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