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