Completed
Pull Request — master (#71)
by Sam
11:59
created

images.php ➔ getPlayerSkin()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 89
Code Lines 85

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 85
nc 2
nop 1
dl 0
loc 89
rs 8.5731
c 0
b 0
f 0

How to fix   Long Method   

Long Method

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:

1
<?php
2
3
function skinImage($uniform)
4
{
5
    $playerSkin = getPlayerSkin(stripArray($uniform, 3));
6
    return "assets/img/uniform/$playerSkin.jpg";
7
}
8
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
99
function getPic($input)
100
{
101
    $carPics = array(
102
        'B_Boat_Armed_01_minigun_F',
103
        'B_Boat_Transport_01_F',
104
        'B_G_Offroad_01_armed_F',
105
        'B_G_Offroad_01_F',
106
        'B_G_Offroad_01_F_1',
107
        'B_G_Van_01_transport_F',
108
        'B_Heli_Light_01_F',
109
        'B_Heli_Transport_01_F',
110
        'B_Lifeboat',
111
        'B_MRAP_01_F',
112
        'B_MRAP_01_hmg_F',
113
        'B_Quadbike_01_F',
114
        'B_SDV_01_F',
115
        'B_Truck_01_ammo_F',
116
        'B_Truck_01_box_F',
117
        'B_Truck_01_covered_F',
118
        'B_Truck_01_transport_F',
119
        'C_Boat_Civil_01_F',
120
        'C_Boat_Civil_01_police_F',
121
        'C_Hatchback_01_F',
122
        'C_Hatchback_01_sport_F',
123
        'C_Offroad_01_F',
124
        'C_Rubberboat',
125
        'C_SUV_01_F',
126
        'C_Van_01_box_F',
127
        'C_Van_01_fuel_F',
128
        'C_Van_01_transport_F',
129
        'I_Heli_light_03_unarmed_F',
130
        'I_Heli_Transport_02_F',
131
        'I_MRAP_03_F',
132
        'I_Truck_02_covered_F',
133
        'I_Truck_02_transport_F',
134
        'O_Heli_Light_02_unarmed_F',
135
        'O_MRAP_02_F'
136
    );
137
    if (in_array($input, $carPics)) {
138
        return $input;
139
    }
140
    return "Default";
141
}