Conditions | 15 |
Paths | 15 |
Total Lines | 99 |
Code Lines | 82 |
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 |
||
94 | protected function getMagentoEditionByYearAndVersion($year, $version) |
||
95 | { |
||
96 | switch ($year) { |
||
97 | case 2008: |
||
98 | if (in_array($version, [ |
||
99 | '1', |
||
100 | '1.1.1', |
||
101 | '1.1.2', |
||
102 | '1.1.3', |
||
103 | '1.1.4', |
||
104 | '1.1.5', |
||
105 | '1.1.6', |
||
106 | '1.1.7', |
||
107 | '1.1.8', |
||
108 | '1.2.0', |
||
109 | '1.2.0.1', |
||
110 | '1.2.0.2', |
||
111 | '1.2.0.3', |
||
112 | '1.2.1', |
||
113 | '1.2.1.1', |
||
114 | '1.2.1.2', |
||
115 | '1.3.0', |
||
116 | '1.3.1', |
||
117 | '1.3.1.1', |
||
118 | '1.3.2', |
||
119 | '1.3.2.1', |
||
120 | '1.3.2.2', |
||
121 | '1.3.2.3', |
||
122 | '1.3.2.4', |
||
123 | '1.3.3.0', |
||
124 | '1.4.0.0', |
||
125 | '1.4.0.1', |
||
126 | '1.4.1.0', |
||
127 | '1.4.1.1', |
||
128 | '1.4.2.0', |
||
129 | ])) { |
||
130 | return Version::EDITION_COMMUNITY; |
||
131 | } |
||
132 | break; |
||
133 | case 2010: |
||
134 | if (in_array($version, [ |
||
135 | '1.5.0.0', |
||
136 | '1.5.0.1', |
||
137 | '1.5.1.0', |
||
138 | '1.6.0.0', |
||
139 | '1.6.1.0', |
||
140 | '1.6.2.0', |
||
141 | ])) { |
||
142 | return Version::EDITION_COMMUNITY; |
||
143 | } |
||
144 | break; |
||
145 | case 2012: |
||
146 | if (in_array($version, [ |
||
147 | '1.7.0.0', |
||
148 | '1.7.0.1', |
||
149 | '1.7.0.2', |
||
150 | ])) { |
||
151 | return Version::EDITION_COMMUNITY; |
||
152 | } |
||
153 | break; |
||
154 | case 2013: |
||
155 | if (in_array($version, [ |
||
156 | '1.8.0.0', |
||
157 | '1.8.1.0', |
||
158 | ])) { |
||
159 | return Version::EDITION_COMMUNITY; |
||
160 | } |
||
161 | break; |
||
162 | case 2014: |
||
163 | if (in_array($version, [ |
||
164 | '1.9.0.0', |
||
165 | '1.9.0.1', |
||
166 | '1.9.1.0', |
||
167 | '1.9.1.1', |
||
168 | ])) { |
||
169 | return Version::EDITION_COMMUNITY; |
||
170 | } |
||
171 | break; |
||
172 | case 2015: |
||
173 | if (in_array($version, [ |
||
174 | '1.9.1.1', |
||
175 | '1.9.2.0', |
||
176 | '1.9.2.1', |
||
177 | '1.9.2.2', |
||
178 | ])) { |
||
179 | return Version::EDITION_COMMUNITY; |
||
180 | } |
||
181 | break; |
||
182 | case 2016: |
||
183 | if (in_array($version, [ |
||
184 | '1.9.2.3', |
||
185 | '1.9.2.4', |
||
186 | ])) { |
||
187 | return Version::EDITION_COMMUNITY; |
||
188 | } |
||
189 | break; |
||
190 | } |
||
191 | return Version::EDITION_ENTERPRISE; |
||
192 | } |
||
193 | } |
||
194 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: