| Conditions | 1 |
| Paths | 1 |
| Total Lines | 64 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| 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 |
||
| 10 | public function getSourceData() |
||
| 11 | { |
||
| 12 | return [ |
||
| 13 | 'AL' => 'Alabama', |
||
| 14 | 'AK' => 'Alaska', |
||
| 15 | 'AS' => 'American Samoa', |
||
| 16 | 'AZ' => 'Arizona', |
||
| 17 | 'AR' => 'Arkansas', |
||
| 18 | 'CA' => 'California', |
||
| 19 | 'CO' => 'Colorado', |
||
| 20 | 'CT' => 'Connecticut', |
||
| 21 | 'DE' => 'Delaware', |
||
| 22 | 'DC' => 'Dist. of Columbia', |
||
| 23 | 'FL' => 'Florida', |
||
| 24 | 'GA' => 'Georgia', |
||
| 25 | 'GU' => 'Guam', |
||
| 26 | 'HI' => 'Hawaii', |
||
| 27 | 'ID' => 'Idaho', |
||
| 28 | 'IL' => 'Illinois', |
||
| 29 | 'IN' => 'Indiana', |
||
| 30 | 'IA' => 'Iowa', |
||
| 31 | 'KS' => 'Kansas', |
||
| 32 | 'KY' => 'Kentucky', |
||
| 33 | 'LA' => 'Louisiana', |
||
| 34 | 'ME' => 'Maine', |
||
| 35 | 'MD' => 'Maryland', |
||
| 36 | 'MH' => 'Marshall Islands', |
||
| 37 | 'MA' => 'Massachusetts', |
||
| 38 | 'MI' => 'Michigan', |
||
| 39 | 'FM' => 'Micronesia', |
||
| 40 | 'MN' => 'Minnesota', |
||
| 41 | 'MS' => 'Mississippi', |
||
| 42 | 'MO' => 'Missouri', |
||
| 43 | 'MT' => 'Montana', |
||
| 44 | 'NE' => 'Nebraska', |
||
| 45 | 'NV' => 'Nevada', |
||
| 46 | 'NH' => 'New Hampshire', |
||
| 47 | 'NJ' => 'New Jersey', |
||
| 48 | 'NM' => 'New Mexico', |
||
| 49 | 'NY' => 'New York', |
||
| 50 | 'NC' => 'North Carolina', |
||
| 51 | 'ND' => 'North Dakota', |
||
| 52 | 'MP' => 'Northern Marianas', |
||
| 53 | 'OH' => 'Ohio', |
||
| 54 | 'OK' => 'Oklahoma', |
||
| 55 | 'OR' => 'Oregon', |
||
| 56 | 'PW' => 'Palau', |
||
| 57 | 'PA' => 'Pennsylvania', |
||
| 58 | 'PR' => 'Puerto Rico', |
||
| 59 | 'RI' => 'Rhode Island', |
||
| 60 | 'SC' => 'South Carolina', |
||
| 61 | 'SD' => 'South Dakota', |
||
| 62 | 'TN' => 'Tennessee', |
||
| 63 | 'TX' => 'Texas', |
||
| 64 | 'UT' => 'Utah', |
||
| 65 | 'VT' => 'Vermont', |
||
| 66 | 'VA' => 'Virginia', |
||
| 67 | 'VI' => 'Virgin Islands', |
||
| 68 | 'WA' => 'Washington', |
||
| 69 | 'WV' => 'West Virginia', |
||
| 70 | 'WI' => 'Wisconsin', |
||
| 71 | 'WY' => 'Wyoming' |
||
| 72 | ]; |
||
| 73 | } |
||
| 74 | } |
||
| 75 |