| Conditions | 2 |
| Paths | 2 |
| Total Lines | 89 |
| Code Lines | 85 |
| Lines | 0 |
| Ratio | 0 % |
| 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 |
||
| 9 | function getPlayerSkin($uniform) |
||
| 10 | { |
||
| 11 | $playerSkins = array( |
||
| 12 | 'U_B_CombatUniform_mcam', |
||
| 13 | 'U_B_CombatUniform_mcam_tshirt', |
||
| 14 | 'U_B_CombatUniform_mcam_vest', |
||
| 15 | 'U_B_GhillieSuit', |
||
| 16 | 'U_B_HeliPilotCoveralls', |
||
| 17 | 'U_B_Wetsuit', |
||
| 18 | 'U_O_CombatUniform_ocamo', |
||
| 19 | 'U_O_GhillieSuit', |
||
| 20 | 'U_O_PilotCoveralls', |
||
| 21 | 'U_O_Wetsuit', |
||
| 22 | 'U_C_Poloshirt_blue', |
||
| 23 | 'U_C_Poloshirt_burgundy', |
||
| 24 | 'U_C_Poloshirt_stripped', |
||
| 25 | 'U_C_Poloshirt_tricolour', |
||
| 26 | 'U_C_Poloshirt_salmon', |
||
| 27 | 'U_C_Poloshirt_redwhite', |
||
| 28 | 'U_C_Commoner1_1', |
||
| 29 | 'U_C_Commoner1_2', |
||
| 30 | 'U_C_Commoner1_3', |
||
| 31 | 'U_Rangemaster', |
||
| 32 | 'U_OrestesBody', |
||
| 33 | 'U_NikosBody', |
||
| 34 | 'U_BasicBody', |
||
| 35 | 'U_B_CombatUniform_mcam_worn', |
||
| 36 | 'U_B_SpecopsUniform_sgg', |
||
| 37 | 'U_B_PilotCoveralls', |
||
| 38 | 'U_O_CombatUniform_oucamo', |
||
| 39 | 'U_O_SpecopsUniform_ocamo', |
||
| 40 | 'U_O_SpecopsUniform_blk', |
||
| 41 | 'U_O_OfficerUniform_ocamo', |
||
| 42 | 'U_I_CombatUniform', |
||
| 43 | 'U_I_CombatUniform_tshirt', |
||
| 44 | 'U_I_CombatUniform_shortsleeve', |
||
| 45 | 'U_I_pilotCoveralls', |
||
| 46 | 'U_I_HeliPilotCoveralls', |
||
| 47 | 'U_I_GhillieSuit', |
||
| 48 | 'U_I_OfficerUniform', |
||
| 49 | 'U_I_Wetsuit', |
||
| 50 | 'U_Competitor', |
||
| 51 | 'U_MillerBody', |
||
| 52 | 'U_KerryBody', |
||
| 53 | 'U_IG_Guerilla1_1', |
||
| 54 | 'U_IG_Guerilla2_1', |
||
| 55 | 'U_IG_Guerilla2_2', |
||
| 56 | 'U_IG_Guerilla2_3', |
||
| 57 | 'U_IG_Guerilla3_1', |
||
| 58 | 'U_IG_Guerilla3_2', |
||
| 59 | 'U_IG_leader', |
||
| 60 | 'U_BG_Guerilla1_1', |
||
| 61 | 'U_BG_Guerilla2_1', |
||
| 62 | 'U_BG_Guerilla2_2', |
||
| 63 | 'U_BG_Guerilla2_3', |
||
| 64 | 'U_BG_Guerilla3_1', |
||
| 65 | 'U_BG_Guerilla3_2', |
||
| 66 | 'U_BG_leader', |
||
| 67 | 'U_OG_Guerilla1_1', |
||
| 68 | 'U_OG_Guerilla2_1', |
||
| 69 | 'U_OG_Guerilla2_2', |
||
| 70 | 'U_OG_Guerilla2_3', |
||
| 71 | 'U_OG_Guerilla3_1', |
||
| 72 | 'U_OG_Guerilla3_2', |
||
| 73 | 'U_OG_leader', |
||
| 74 | 'U_C_Poor_1', |
||
| 75 | 'U_C_Poor_2', |
||
| 76 | 'U_C_WorkerCoveralls', |
||
| 77 | 'U_C_HunterBody_grn', |
||
| 78 | 'U_C_Poor_shorts_1', |
||
| 79 | 'U_C_Commoner_shorts', |
||
| 80 | 'U_C_ShirtSurfer_shorts', |
||
| 81 | 'U_C_TeeSurfer_shorts_1', |
||
| 82 | 'U_C_TeeSurfer_shorts_2', |
||
| 83 | 'U_B_CTRG_1', |
||
| 84 | 'U_B_CTRG_2', |
||
| 85 | 'U_B_CTRG_3', |
||
| 86 | 'U_B_survival_uniform', |
||
| 87 | 'U_I_G_Story_Protagonist_F', |
||
| 88 | 'U_I_G_resistanceLeader_F', |
||
| 89 | 'U_C_Journalist', |
||
| 90 | 'U_C_Scientist', |
||
| 91 | 'U_NikosAgedBody' |
||
| 92 | ); |
||
| 93 | if (in_array($uniform, $playerSkins)) { |
||
| 94 | return $uniform; |
||
| 95 | } |
||
| 96 | return "Default"; |
||
| 97 | } |
||
| 98 | |||
| 141 | } |