| Conditions | 12 |
| Paths | 4 |
| Total Lines | 22 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| 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 |
||
| 25 | public function configureDefaults( |
||
| 26 | RequestQueue $queue, |
||
| 27 | bool $enabled, |
||
| 28 | bool $default, |
||
| 29 | bool $antiSpoof, |
||
| 30 | bool $titleBlacklist, |
||
| 31 | bool $isTarget |
||
| 32 | ) { |
||
| 33 | // always allow enabling a queue |
||
| 34 | if ($enabled) { |
||
| 35 | $queue->setEnabled($enabled); |
||
| 36 | } |
||
| 37 | |||
| 38 | // only allow other enable-flag changes if we're not a default |
||
| 39 | if (!($queue->isDefault() || $queue->isDefaultAntispoof() || $queue->isDefaultTitleBlacklist() || $isTarget)) { |
||
| 40 | $queue->setEnabled($enabled); |
||
| 41 | } |
||
| 42 | |||
| 43 | // only allow enabling the default flags, and only when we're enabled. |
||
| 44 | $queue->setDefault(($queue->isDefault() || $default) && $queue->isEnabled()); |
||
| 45 | $queue->setDefaultAntispoof(($queue->isDefaultAntispoof() || $antiSpoof) && $queue->isEnabled()); |
||
| 46 | $queue->setDefaultTitleBlacklist(($queue->isDefaultTitleBlacklist() || $titleBlacklist) && $queue->isEnabled()); |
||
| 47 | } |
||
| 85 | } |