Conditions | 22 |
Paths | > 20000 |
Total Lines | 397 |
Code Lines | 194 |
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 |
||
25 | public function addLanguage($data) |
||
26 | { |
||
27 | $this->db->query(" |
||
28 | INSERT INTO language |
||
29 | SET name = '" . $this->db->escape($data['name']) . "', |
||
30 | code = '" . $this->db->escape($data['code']) . "', |
||
31 | locale = '" . $this->db->escape($data['locale']) . "', |
||
32 | sort_order = '" . $this->db->escape($data['sort_order']) . "', |
||
33 | status = '" . (int)$data['status'] . "' |
||
34 | "); |
||
35 | |||
36 | $this->cache->delete('language'); |
||
37 | |||
38 | $language_id = $this->db->getLastId(); |
||
39 | |||
40 | // Blog Article |
||
41 | $query = $this->db->query(" |
||
42 | SELECT * |
||
43 | FROM article_description |
||
44 | WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' |
||
45 | "); |
||
46 | |||
47 | foreach ($query->rows as $article) { |
||
48 | $this->db->query(" |
||
49 | INSERT INTO article_description |
||
50 | SET article_id = '" . (int)$article['article_id'] . "', |
||
51 | language_id = '" . (int)$language_id . "', |
||
52 | name = '" . $this->db->escape($article['name']) . "', |
||
53 | description = '" . $this->db->escape($article['description']) . "', |
||
54 | meta_description = '" . $this->db->escape($article['meta_description']) . "', |
||
55 | meta_title = '" . $this->db->escape($article['meta_title']) . "', |
||
56 | meta_h1 = '" . $this->db->escape($article['meta_h1']) . "', |
||
57 | tag = '" . $this->db->escape($article['tag']) . "' |
||
58 | "); |
||
59 | } |
||
60 | $this->cache->delete('article'); |
||
61 | |||
62 | // Blog Category |
||
63 | $query = $this->db->query(" |
||
64 | SELECT * |
||
65 | FROM blog_category_description |
||
66 | WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' |
||
67 | "); |
||
68 | |||
69 | foreach ($query->rows as $blog_category) { |
||
70 | $this->db->query(" |
||
71 | INSERT INTO blog_category_description |
||
72 | SET blog_category_id = '" . (int)$blog_category['blog_category_id'] . "', |
||
73 | language_id = '" . (int)$language_id . "', |
||
74 | name = '" . $this->db->escape($blog_category['name']) . "', |
||
75 | description = '" . $this->db->escape($blog_category['description']) . "', |
||
76 | meta_description = '" . $this->db->escape($blog_category['meta_description']) . "', |
||
77 | meta_title = '" . $this->db->escape($blog_category['meta_title']) . "', |
||
78 | meta_h1 = '" . $this->db->escape($blog_category['meta_h1']) . "' |
||
79 | "); |
||
80 | } |
||
81 | |||
82 | // Menu |
||
83 | $query = $this->db->query(" |
||
84 | SELECT * |
||
85 | FROM custommenu_description |
||
86 | WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' |
||
87 | "); |
||
88 | |||
89 | foreach ($query->rows as $custommenu) { |
||
90 | $this->db->query(" |
||
91 | INSERT INTO custommenu_description |
||
92 | SET custommenu_id = '" . (int)$custommenu['custommenu_id'] . "', |
||
93 | language_id = '" . (int)$language_id . "', |
||
94 | name = '" . $this->db->escape($custommenu['name']) . "', |
||
95 | link = '" . $this->db->escape($custommenu['link']) . "' |
||
96 | "); |
||
97 | } |
||
98 | |||
99 | // Menu Child |
||
100 | $query = $this->db->query(" |
||
101 | SELECT * |
||
102 | FROM custommenu_child_description |
||
103 | WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' |
||
104 | "); |
||
105 | |||
106 | foreach ($query->rows as $custommenu_child) { |
||
107 | $this->db->query(" |
||
108 | INSERT INTO custommenu_child_description |
||
109 | SET custommenu_child_id = '" . (int)$custommenu_child['custommenu_child_id'] . "', |
||
110 | custommenu_id = '" . (int)$custommenu_child['custommenu_id'] . "', |
||
111 | language_id = '" . (int)$language_id . "', |
||
112 | name = '" . $this->db->escape($custommenu_child['name']) . "', |
||
113 | link = '" . $this->db->escape($custommenu_child['link']) . "' |
||
114 | "); |
||
115 | } |
||
116 | |||
117 | // Attribute |
||
118 | $query = $this->db->query(" |
||
119 | SELECT * |
||
120 | FROM attribute_description |
||
121 | WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' |
||
122 | "); |
||
123 | |||
124 | foreach ($query->rows as $attribute) { |
||
125 | $this->db->query(" |
||
126 | INSERT INTO attribute_description |
||
127 | SET attribute_id = '" . (int)$attribute['attribute_id'] . "', |
||
128 | language_id = '" . (int)$language_id . "', |
||
129 | name = '" . $this->db->escape($attribute['name']) . "' |
||
130 | "); |
||
131 | } |
||
132 | |||
133 | // Attribute Group |
||
134 | $query = $this->db->query(" |
||
135 | SELECT * |
||
136 | FROM attribute_group_description |
||
137 | WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' |
||
138 | "); |
||
139 | |||
140 | foreach ($query->rows as $attribute_group) { |
||
141 | $this->db->query(" |
||
142 | INSERT INTO attribute_group_description |
||
143 | SET attribute_group_id = '" . (int)$attribute_group['attribute_group_id'] . "', |
||
144 | language_id = '" . (int)$language_id . "', |
||
145 | name = '" . $this->db->escape($attribute_group['name']) . "' |
||
146 | "); |
||
147 | } |
||
148 | |||
149 | $this->cache->delete('attribute'); |
||
150 | |||
151 | // Banner |
||
152 | $query = $this->db->query(" |
||
153 | SELECT * |
||
154 | FROM banner_image |
||
155 | WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' |
||
156 | "); |
||
157 | |||
158 | foreach ($query->rows as $banner_image) { |
||
159 | $this->db->query(" |
||
160 | INSERT INTO banner_image |
||
161 | SET banner_id = '" . (int)$banner_image['banner_id'] . "', |
||
162 | language_id = '" . (int)$language_id . "', |
||
163 | title = '" . $this->db->escape($banner_image['title']) . "', |
||
164 | link = '" . $this->db->escape($banner_image['link']) . "', |
||
165 | image = '" . $this->db->escape($banner_image['image']) . "', |
||
166 | sort_order = '" . (int)$banner_image['sort_order'] . "' |
||
167 | "); |
||
168 | } |
||
169 | |||
170 | $this->cache->delete('banner'); |
||
171 | |||
172 | // Category |
||
173 | $query = $this->db->query(" |
||
174 | SELECT * |
||
175 | FROM category_description |
||
176 | WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' |
||
177 | "); |
||
178 | |||
179 | foreach ($query->rows as $category) { |
||
180 | $this->db->query(" |
||
181 | INSERT INTO category_description |
||
182 | SET category_id = '" . (int)$category['category_id'] . "', |
||
183 | language_id = '" . (int)$language_id . "', |
||
184 | name = '" . $this->db->escape($category['name']) . "', |
||
185 | description = '" . $this->db->escape($category['description']) . "', |
||
186 | meta_title = '" . $this->db->escape($category['meta_title']) . "', |
||
187 | meta_description = '" . $this->db->escape($category['meta_description']) . "' |
||
188 | "); |
||
189 | } |
||
190 | |||
191 | $this->cache->delete('category'); |
||
192 | |||
193 | // Customer Group |
||
194 | $query = $this->db->query(" |
||
195 | SELECT * |
||
196 | FROM customer_group_description |
||
197 | WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' |
||
198 | "); |
||
199 | |||
200 | foreach ($query->rows as $customer_group) { |
||
201 | $this->db->query(" |
||
202 | INSERT INTO customer_group_description |
||
203 | SET customer_group_id = '" . (int)$customer_group['customer_group_id'] . "', |
||
204 | language_id = '" . (int)$language_id . "', |
||
205 | name = '" . $this->db->escape($customer_group['name']) . "', |
||
206 | description = '" . $this->db->escape($customer_group['description']) . "' |
||
207 | "); |
||
208 | } |
||
209 | |||
210 | // Custom Field |
||
211 | $query = $this->db->query(" |
||
212 | SELECT * |
||
213 | FROM custom_field_description |
||
214 | WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' |
||
215 | "); |
||
216 | |||
217 | foreach ($query->rows as $custom_field) { |
||
218 | $this->db->query(" |
||
219 | INSERT INTO custom_field_description |
||
220 | SET custom_field_id = '" . (int)$custom_field['custom_field_id'] . "', |
||
221 | language_id = '" . (int)$language_id . "', |
||
222 | name = '" . $this->db->escape($custom_field['name']) . "' |
||
223 | "); |
||
224 | } |
||
225 | |||
226 | // Custom Field Value |
||
227 | $query = $this->db->query(" |
||
228 | SELECT * |
||
229 | FROM custom_field_value_description |
||
230 | WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' |
||
231 | "); |
||
232 | |||
233 | foreach ($query->rows as $custom_field_value) { |
||
234 | $this->db->query(" |
||
235 | INSERT INTO custom_field_value_description |
||
236 | SET custom_field_value_id = '" . (int)$custom_field_value['custom_field_value_id'] . "', |
||
237 | language_id = '" . (int)$language_id . "', |
||
238 | custom_field_id = '" . (int)$custom_field_value['custom_field_id'] . "', |
||
239 | name = '" . $this->db->escape($custom_field_value['name']) . "' |
||
240 | "); |
||
241 | } |
||
242 | |||
243 | // Download |
||
244 | $query = $this->db->query(" |
||
245 | SELECT * |
||
246 | FROM download_description |
||
247 | WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' |
||
248 | "); |
||
249 | |||
250 | foreach ($query->rows as $download) { |
||
251 | $this->db->query(" |
||
252 | INSERT INTO download_description |
||
253 | SET download_id = '" . (int)$download['download_id'] . "', |
||
254 | language_id = '" . (int)$language_id . "', |
||
255 | name = '" . $this->db->escape($download['name']) . "' |
||
256 | "); |
||
257 | } |
||
258 | |||
259 | // Filter |
||
260 | $query = $this->db->query(" |
||
261 | SELECT * |
||
262 | FROM filter_description |
||
263 | WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' |
||
264 | "); |
||
265 | |||
266 | foreach ($query->rows as $filter) { |
||
267 | $this->db->query(" |
||
268 | INSERT INTO filter_description |
||
269 | SET filter_id = '" . (int)$filter['filter_id'] . "', |
||
270 | language_id = '" . (int)$language_id . "', |
||
271 | filter_group_id = '" . (int)$filter['filter_group_id'] . "', |
||
272 | name = '" . $this->db->escape($filter['name']) . "' |
||
273 | "); |
||
274 | } |
||
275 | |||
276 | // Filter Group |
||
277 | $query = $this->db->query(" |
||
278 | SELECT * |
||
279 | FROM filter_group_description |
||
280 | WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' |
||
281 | "); |
||
282 | |||
283 | foreach ($query->rows as $filter_group) { |
||
284 | $this->db->query(" |
||
285 | INSERT INTO filter_group_description |
||
286 | SET filter_group_id = '" . (int)$filter_group['filter_group_id'] . "', |
||
287 | language_id = '" . (int)$language_id . "', |
||
288 | name = '" . $this->db->escape($filter_group['name']) . "' |
||
289 | "); |
||
290 | } |
||
291 | |||
292 | // Information |
||
293 | $query = $this->db->query(" |
||
294 | SELECT * |
||
295 | FROM information_description |
||
296 | WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' |
||
297 | "); |
||
298 | |||
299 | foreach ($query->rows as $information) { |
||
300 | $this->db->query(" |
||
301 | INSERT INTO information_description |
||
302 | SET information_id = '" . (int)$information['information_id'] . "', |
||
303 | language_id = '" . (int)$language_id . "', |
||
304 | title = '" . $this->db->escape($information['title']) . "', |
||
305 | description = '" . $this->db->escape($information['description']) . "', |
||
306 | meta_title = '" . $this->db->escape($information['meta_title']) . "', |
||
307 | meta_description = '" . $this->db->escape($information['meta_description']) . "' |
||
308 | "); |
||
309 | } |
||
310 | |||
311 | $this->cache->delete('information'); |
||
312 | |||
313 | // Option |
||
314 | $query = $this->db->query(" |
||
315 | SELECT * |
||
316 | FROM option_description |
||
317 | WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' |
||
318 | "); |
||
319 | |||
320 | foreach ($query->rows as $option) { |
||
321 | $this->db->query(" |
||
322 | INSERT INTO option_description |
||
323 | SET option_id = '" . (int)$option['option_id'] . "', |
||
324 | language_id = '" . (int)$language_id . "', |
||
325 | name = '" . $this->db->escape($option['name']) . "' |
||
326 | "); |
||
327 | } |
||
328 | |||
329 | // Option Value |
||
330 | $query = $this->db->query(" |
||
331 | SELECT * |
||
332 | FROM option_value_description |
||
333 | WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' |
||
334 | "); |
||
335 | |||
336 | foreach ($query->rows as $option_value) { |
||
337 | $this->db->query(" |
||
338 | INSERT INTO option_value_description |
||
339 | SET option_value_id = '" . (int)$option_value['option_value_id'] . "', |
||
340 | language_id = '" . (int)$language_id . "', |
||
341 | option_id = '" . (int)$option_value['option_id'] . "', |
||
342 | name = '" . $this->db->escape($option_value['name']) . "' |
||
343 | "); |
||
344 | } |
||
345 | |||
346 | // Order Status |
||
347 | $query = $this->db->query(" |
||
348 | SELECT * |
||
349 | FROM order_status |
||
350 | WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' |
||
351 | "); |
||
352 | |||
353 | foreach ($query->rows as $order_status) { |
||
354 | $this->db->query(" |
||
355 | INSERT INTO order_status |
||
356 | SET order_status_id = '" . (int)$order_status['order_status_id'] . "', |
||
357 | language_id = '" . (int)$language_id . "', |
||
358 | name = '" . $this->db->escape($order_status['name']) . "' |
||
359 | "); |
||
360 | } |
||
361 | |||
362 | $this->cache->delete('order_status'); |
||
363 | |||
364 | // Product |
||
365 | $query = $this->db->query(" |
||
366 | SELECT * |
||
367 | FROM product_description |
||
368 | WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' |
||
369 | "); |
||
370 | |||
371 | foreach ($query->rows as $product) { |
||
372 | $this->db->query(" |
||
373 | INSERT INTO product_description |
||
374 | SET product_id = '" . (int)$product['product_id'] . "', |
||
375 | language_id = '" . (int)$language_id . "', |
||
376 | name = '" . $this->db->escape($product['name']) . "', |
||
377 | description = '" . $this->db->escape($product['description']) . "', |
||
378 | tag = '" . $this->db->escape($product['tag']) . "', |
||
379 | meta_title = '" . $this->db->escape($product['meta_title']) . "', |
||
380 | meta_description = '" . $this->db->escape($product['meta_description']) . "' |
||
381 | "); |
||
382 | } |
||
383 | |||
384 | $this->cache->delete('product'); |
||
385 | |||
386 | // Product Attribute |
||
387 | $query = $this->db->query(" |
||
388 | SELECT * |
||
389 | FROM product_attribute |
||
390 | WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' |
||
391 | "); |
||
392 | |||
393 | foreach ($query->rows as $product_attribute) { |
||
394 | $this->db->query(" |
||
395 | INSERT INTO product_attribute |
||
396 | SET product_id = '" . (int)$product_attribute['product_id'] . "', |
||
397 | attribute_id = '" . (int)$product_attribute['attribute_id'] . "', |
||
398 | language_id = '" . (int)$language_id . "', |
||
399 | text = '" . $this->db->escape($product_attribute['text']) . "' |
||
400 | "); |
||
401 | } |
||
402 | |||
403 | // Stock Status |
||
404 | $query = $this->db->query(" |
||
405 | SELECT * |
||
406 | FROM stock_status |
||
407 | WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' |
||
408 | "); |
||
409 | |||
410 | foreach ($query->rows as $stock_status) { |
||
411 | $this->db->query(" |
||
412 | INSERT INTO stock_status |
||
413 | SET stock_status_id = '" . (int)$stock_status['stock_status_id'] . "', |
||
414 | language_id = '" . (int)$language_id . "', |
||
415 | name = '" . $this->db->escape($stock_status['name']) . "' |
||
416 | "); |
||
417 | } |
||
418 | |||
419 | $this->cache->delete('stock_status'); |
||
420 | |||
421 | return $language_id; |
||
422 | } |
||
686 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.