| Conditions | 1 |
| Paths | 1 |
| Total Lines | 75 |
| Code Lines | 37 |
| 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 |
||
| 148 | protected function configureOptions(OptionsResolver $resolver): void |
||
| 149 | { |
||
| 150 | $resolver |
||
| 151 | ->setDefined('schedule') |
||
| 152 | ->setNormalizer('schedule', LazyOption::findOneBy($this->scheduleRepository, 'code')) |
||
| 153 | ->setAllowedTypes('schedule', ['null', 'string']) |
||
| 154 | |||
| 155 | ->setDefined('command') |
||
| 156 | ->setAllowedTypes('command', 'string') |
||
| 157 | |||
| 158 | ->setDefined('args') |
||
| 159 | ->setDefault('args', []) |
||
| 160 | ->setAllowedTypes('args', 'array') |
||
| 161 | |||
| 162 | ->setDefined('state') |
||
| 163 | ->setAllowedTypes('state', ['null', 'string']) |
||
| 164 | |||
| 165 | ->setDefined('queue') |
||
| 166 | ->setAllowedTypes('queue', ['null', 'string']) |
||
| 167 | |||
| 168 | ->setDefault('priority', function (Options $options): int { |
||
|
|
|||
| 169 | return $this->faker->randomElement([ |
||
| 170 | JobInterface::PRIORITY_LOW, |
||
| 171 | JobInterface::PRIORITY_DEFAULT, |
||
| 172 | JobInterface::PRIORITY_HIGH, |
||
| 173 | ]); |
||
| 174 | }) |
||
| 175 | ->setAllowedTypes('priority', ['int', 'null']) |
||
| 176 | |||
| 177 | // ->setDefined('created_at') |
||
| 178 | // ->setAllowedTypes('created_at', ['null', 'string']) |
||
| 179 | // |
||
| 180 | // ->setDefined('started_at') |
||
| 181 | // ->setAllowedTypes('started_at', ['null', 'string']) |
||
| 182 | // |
||
| 183 | // ->setDefined('checked_at') |
||
| 184 | // ->setAllowedTypes('checked_at', ['null', 'string']) |
||
| 185 | // |
||
| 186 | // ->setDefined('closed_at') |
||
| 187 | // ->setAllowedTypes('closed_at', ['null', 'string']) |
||
| 188 | |||
| 189 | ->setDefined('execute_after') |
||
| 190 | ->setAllowedTypes('execute_after', ['null', 'string']) |
||
| 191 | |||
| 192 | // // @todo Decide how to identify |
||
| 193 | // ->setNormalizer('dependencies', LazyOption::findBy($this->jobRepository, '...')) |
||
| 194 | // ->setAllowedTypes('dependencies', 'array') |
||
| 195 | |||
| 196 | ->setDefined('worker_name') |
||
| 197 | ->setAllowedTypes('worker_name', ['null', 'string']) |
||
| 198 | |||
| 199 | ->setDefined('output') |
||
| 200 | ->setAllowedTypes('output', ['null', 'string']) |
||
| 201 | |||
| 202 | ->setDefined('error_output') |
||
| 203 | ->setAllowedTypes('error_output', ['null', 'string']) |
||
| 204 | |||
| 205 | ->setDefined('exit_code') |
||
| 206 | ->setAllowedTypes('exit_code', ['null', 'int']) |
||
| 207 | |||
| 208 | ->setDefined('max_runtime') |
||
| 209 | ->setAllowedTypes('max_runtime', ['null', 'int']) |
||
| 210 | |||
| 211 | ->setDefined('max_retries') |
||
| 212 | ->setAllowedTypes('max_retries', ['null', 'int']) |
||
| 213 | |||
| 214 | // // @todo Decide how to identify |
||
| 215 | // ->setNormalizer('retry_jobs', LazyOption::findOneBy($this->jobRepository, '...')) |
||
| 216 | // ->setAllowedTypes('original_job', ['null', 'object']) |
||
| 217 | |||
| 218 | ->setDefined('retry_jobs') |
||
| 219 | ->setNormalizer('retry_jobs', function ($options) { |
||
| 220 | return $this->faker->numberBetween(0, 4); |
||
| 221 | }) |
||
| 222 | ->setAllowedTypes('retry_jobs', 'int') |
||
| 223 | ; |
||
| 226 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.