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