Conditions | 2 |
Paths | 2 |
Total Lines | 70 |
Lines | 0 |
Ratio | 0 % |
Tests | 3 |
CRAP Score | 2.0625 |
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 | } |
||
13 | |||
14 | return [ |
||
15 | 4 | 'Detection' => [ |
|
16 | 'Rules' => [ |
||
17 | 'Bots' => [ |
||
18 | 'active' => 1, |
||
19 | 'score' => 1, |
||
20 | 'params' => 'sensu' |
||
21 | ], |
||
22 | 'Html' => [ |
||
23 | 'active' => 1, |
||
24 | 'score' => 1, |
||
25 | 'params' => '', |
||
26 | ], |
||
27 | 'Numeric' => [ |
||
28 | 'active' => 1, |
||
29 | 'score' => 1, |
||
30 | 'params' => '', |
||
31 | ], |
||
32 | 'Url' => [ |
||
33 | 'active' => 1, |
||
34 | 'score' => 1, |
||
35 | 'params' => '', |
||
36 | ], |
||
37 | 'DisposableEmail' => [ |
||
38 | 'active' => 1, |
||
39 | 'score' => 10, |
||
40 | 'params' => '', |
||
41 | ], |
||
42 | 'InvalidEmail' => [ |
||
43 | 'active' => 1, |
||
44 | 'score' => 1, |
||
45 | 'params' => '', |
||
46 | ], |
||
47 | 'QueryStringKey' => [ |
||
48 | 'active' => 1, |
||
49 | 'score' => 1, |
||
50 | 'params' => '', |
||
51 | ], |
||
52 | 'QueryStringValue' => [ |
||
53 | 'active' => 1, |
||
54 | 'score' => 1, |
||
55 | 'params' => '', |
||
56 | ], |
||
57 | 'DifferentCountry' => [ |
||
58 | 'active' => 1, |
||
59 | 'score' => 10, |
||
60 | 'params' => '', |
||
61 | ], |
||
62 | 'Country' => [ |
||
63 | 'active' => 1, |
||
64 | 'score' => 10, |
||
65 | 'params' => '', |
||
66 | ], |
||
67 | 'Xss' => [ |
||
68 | 'active' => 1, |
||
69 | 'score' => 10, |
||
70 | 'params' => '', |
||
71 | ] |
||
72 | ] |
||
73 | ] |
||
74 | |||
75 | ]; |
||
76 | |||
77 | } |
||
78 | |||
83 | } |
This check marks method names that have not been written in camelCase.
In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes
databaseConnectionString
.