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