| Conditions | 10 |
| Paths | 2 |
| Total Lines | 30 |
| Code Lines | 22 |
| 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 |
||
| 21 | public function run() |
||
| 22 | { |
||
| 23 | |||
| 24 | //Empty the countries table |
||
| 25 | \DB::table(\Config::get('countries.table_name'))->delete(); |
||
| 26 | |||
| 27 | //Get all of the countries |
||
| 28 | $countries = Countries::getList(); |
||
| 29 | foreach ($countries as $countryId => $country) { |
||
| 30 | \DB::table(\Config::get('countries.table_name'))->insert(array( |
||
| 31 | 'id' => $countryId, |
||
| 32 | 'capital' => ((isset($country['capital'])) ? $country['capital'] : null), |
||
| 33 | 'citizenship' => ((isset($country['citizenship'])) ? $country['citizenship'] : null), |
||
| 34 | 'country_code' => $country['country-code'], |
||
| 35 | 'currency' => ((isset($country['currency'])) ? $country['currency'] : null), |
||
| 36 | 'currency_code' => ((isset($country['currency_code'])) ? $country['currency_code'] : null), |
||
| 37 | 'currency_sub_unit' => ((isset($country['currency_sub_unit'])) ? $country['currency_sub_unit'] : null), |
||
| 38 | 'full_name' => ((isset($country['full_name'])) ? $country['full_name'] : null), |
||
| 39 | 'iso_3166_2' => $country['iso_3166_2'], |
||
| 40 | 'iso_3166_3' => $country['iso_3166_3'], |
||
| 41 | 'name' => $country['name'], |
||
| 42 | 'region_code' => $country['region-code'], |
||
| 43 | 'sub_region_code' => $country['sub-region-code'], |
||
| 44 | 'eea' => (bool)$country['eea'], |
||
| 45 | 'calling_code' => $country['calling_code'], |
||
| 46 | 'currency_symbol' => ((isset($country['currency_symbol'])) ? $country['currency_symbol'] : null), |
||
| 47 | 'flag' => ((isset($country['flag'])) ? $country['flag'] : null), |
||
| 48 | )); |
||
| 49 | } |
||
| 50 | } |
||
| 51 | } |
||
| 52 |