Conditions | 2 |
Paths | 2 |
Total Lines | 70 |
Lines | 0 |
Ratio | 0 % |
Tests | 47 |
CRAP Score | 2 |
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 |
||
8 | 4 | public function getOptions() |
|
9 | { |
||
10 | 4 | if ($this->yaml_loaded()) { |
|
11 | return yaml_parse_file(__DIR__ . '/Options.yml'); |
||
12 | } else { |
||
13 | |||
14 | return [ |
||
15 | 'Detection' => [ |
||
16 | 'Rules' => [ |
||
17 | 'Bots' => [ |
||
18 | 4 | 'active' => 1, |
|
19 | 4 | 'score' => 1, |
|
20 | 'params' => 'sensu' |
||
21 | 4 | ], |
|
22 | 'Html' => [ |
||
23 | 4 | 'active' => 1, |
|
24 | 4 | 'score' => 1, |
|
25 | 4 | 'params' => '', |
|
26 | 4 | ], |
|
27 | 'Numeric' => [ |
||
28 | 4 | 'active' => 1, |
|
29 | 4 | 'score' => 1, |
|
30 | 4 | 'params' => '', |
|
31 | 4 | ], |
|
32 | 'Url' => [ |
||
33 | 4 | 'active' => 1, |
|
34 | 4 | 'score' => 1, |
|
35 | 4 | 'params' => '', |
|
36 | 4 | ], |
|
37 | 'DisposableEmail' => [ |
||
38 | 4 | 'active' => 1, |
|
39 | 4 | 'score' => 10, |
|
40 | 4 | 'params' => '', |
|
41 | 4 | ], |
|
42 | 'InvalidEmail' => [ |
||
43 | 4 | 'active' => 1, |
|
44 | 4 | 'score' => 1, |
|
45 | 4 | 'params' => '', |
|
46 | 4 | ], |
|
47 | 'QueryStringKey' => [ |
||
48 | 4 | 'active' => 1, |
|
49 | 4 | 'score' => 1, |
|
50 | 4 | 'params' => '', |
|
51 | 4 | ], |
|
52 | 'QueryStringValue' => [ |
||
53 | 4 | 'active' => 1, |
|
54 | 4 | 'score' => 1, |
|
55 | 4 | 'params' => '', |
|
56 | 4 | ], |
|
57 | 'DifferentCountry' => [ |
||
58 | 4 | 'active' => 1, |
|
59 | 4 | 'score' => 10, |
|
60 | 4 | 'params' => '', |
|
61 | 4 | ], |
|
62 | 'Country' => [ |
||
63 | 4 | 'active' => 1, |
|
64 | 4 | 'score' => 10, |
|
65 | 4 | 'params' => '', |
|
66 | 4 | ], |
|
67 | 'Xss' => [ |
||
68 | 4 | 'active' => 1, |
|
69 | 4 | 'score' => 10, |
|
70 | 4 | 'params' => '', |
|
71 | ] |
||
72 | 4 | ] |
|
73 | 4 | ] |
|
74 | |||
75 | 4 | ]; |
|
76 | } |
||
77 | } |
||
78 | |||
83 | } |