Conditions | 1 |
Paths | 1 |
Total Lines | 55 |
Code Lines | 36 |
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 |
||
12 | public function run() |
||
13 | { |
||
14 | $countries = [ |
||
15 | ['id' => 1, 'code' => 'gr'], |
||
16 | ['id' => 2, 'code' => 'fr'], |
||
17 | ['id' => 3, 'code' => 'en'], |
||
18 | ['id' => 4, 'code' => 'de'], |
||
19 | ]; |
||
20 | |||
21 | $this->createCountries($countries); |
||
22 | |||
23 | $countryTranslations = [ |
||
24 | ['country_id' => 1, 'locale' => 'el', 'name' => 'Ελλάδα'], |
||
25 | ['country_id' => 1, 'locale' => 'fr', 'name' => 'Grèce'], |
||
26 | ['country_id' => 1, 'locale' => 'en', 'name' => 'Greece'], |
||
27 | ['country_id' => 1, 'locale' => 'de', 'name' => 'Griechenland'], |
||
28 | ['country_id' => 2, 'locale' => 'en', 'name' => 'France'], |
||
29 | ]; |
||
30 | |||
31 | $this->createCountryTranslations($countryTranslations); |
||
32 | |||
33 | $cities = [ |
||
34 | ['id' => 1, 'country_id' => 1], |
||
35 | ]; |
||
36 | |||
37 | $this->createCities($cities); |
||
38 | |||
39 | $cityTranslations = [ |
||
40 | ['city_id' => 1, 'locale' => 'el', 'name' => 'Αθήνα'], |
||
41 | ['city_id' => 1, 'locale' => 'fr', 'name' => 'Athènes'], |
||
42 | ['city_id' => 1, 'locale' => 'en', 'name' => 'Athens'], |
||
43 | ['city_id' => 1, 'locale' => 'de', 'name' => 'Athen'], |
||
44 | ]; |
||
45 | |||
46 | $this->createCityTranslations($cityTranslations); |
||
47 | |||
48 | $vegetables = [ |
||
49 | ['vegetable_identity' => 1], |
||
50 | ['vegetable_identity' => 2], |
||
51 | ]; |
||
52 | |||
53 | $this->createVegetables($vegetables); |
||
54 | |||
55 | $vegetableTranslations = [ |
||
56 | ['vegetable_identity' => 1, 'locale' => 'en', 'name' => 'zucchini'], |
||
57 | ['vegetable_identity' => 1, 'locale' => 'en-GB', 'name' => 'courgette'], |
||
58 | ['vegetable_identity' => 1, 'locale' => 'en-US', 'name' => 'zucchini'], |
||
59 | ['vegetable_identity' => 1, 'locale' => 'de', 'name' => 'Zucchini'], |
||
60 | ['vegetable_identity' => 1, 'locale' => 'de-CH', 'name' => 'Zucchetti'], |
||
61 | ['vegetable_identity' => 2, 'locale' => 'en', 'name' => 'aubergine'], |
||
62 | ['vegetable_identity' => 2, 'locale' => 'en-US', 'name' => 'eggplant'], |
||
63 | ]; |
||
64 | |||
65 | $this->createVegetableTranslations($vegetableTranslations); |
||
66 | } |
||
67 | |||
130 |
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.