Conditions | 1 |
Paths | 1 |
Total Lines | 61 |
Code Lines | 42 |
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 |
||
10 | public function humanReadableBytesProvider() |
||
11 | { |
||
12 | return array( |
||
13 | '1 byte' => array( |
||
14 | 1, |
||
15 | array( |
||
16 | 'value' => 1.0, |
||
17 | 'unit' => 'B', |
||
18 | ), |
||
19 | ), |
||
20 | '1023 bytes' => array( |
||
21 | 1023, |
||
22 | array( |
||
23 | 'value' => 1023.0, |
||
24 | 'unit' => 'B', |
||
25 | ), |
||
26 | ), |
||
27 | '1024 bytes' => array( |
||
28 | 1024, |
||
29 | array( |
||
30 | 'value' => 1.0, |
||
31 | 'unit' => 'KB', |
||
32 | ), |
||
33 | ), |
||
34 | '1 meg' => array( |
||
35 | pow(2, 20), |
||
36 | array( |
||
37 | 'value' => 1.0, |
||
38 | 'unit' => 'MB', |
||
39 | ), |
||
40 | ), |
||
41 | '1 gig' => array( |
||
42 | pow(2, 30), |
||
43 | array( |
||
44 | 'value' => 1.0, |
||
45 | 'unit' => 'GB', |
||
46 | ), |
||
47 | ), |
||
48 | '1 tig' => array( |
||
49 | pow(2, 40), |
||
50 | array( |
||
51 | 'value' => 1.0, |
||
52 | 'unit' => 'TB', |
||
53 | ), |
||
54 | ), |
||
55 | '>1 tig' => array( |
||
56 | pow(2, 50), |
||
57 | array( |
||
58 | 'value' => 1024.0, |
||
59 | 'unit' => 'TB', |
||
60 | ), |
||
61 | ), |
||
62 | 'halfway' => array( |
||
63 | 15000, |
||
64 | array( |
||
65 | 'value' => 15000 / 1024, |
||
66 | 'unit' => 'KB', |
||
67 | ), |
||
68 | ), |
||
69 | ); |
||
70 | } |
||
71 | |||
81 |